mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
348e76fc8e
Uses new httpclient package from grafana-plugin-sdk-go introduced via grafana/grafana-plugin-sdk-go#328. Replaces the GetHTTPClient, GetTransport, GetTLSConfig methods defined on DataSource model. Longer-term the goal is to migrate core HTTP backend data sources to use the SDK contracts and using httpclient.Provider for creating HTTP clients and such. Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
25 lines
755 B
Go
25 lines
755 B
Go
package tempo
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestTempo(t *testing.T) {
|
|
plug, err := New(httpclient.NewProvider())(&models.DataSource{})
|
|
executor := plug.(*tempoExecutor)
|
|
require.NoError(t, err)
|
|
|
|
t.Run("createRequest should set Auth header when basic auth is true ", func(t *testing.T) {
|
|
req, err := executor.createRequest(context.Background(), &models.DataSource{BasicAuth: true, BasicAuthUser: "john", BasicAuthPassword: "pass"}, "traceID")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, 2, len(req.Header))
|
|
assert.NotEqual(t, req.Header.Get("Authorization"), "")
|
|
})
|
|
}
|