Files
grafana/pkg/tsdb/prometheus/buffered/client_test.go
Andrej Ocenas 3df34fe064 Prometheus: Remove cache, pass headers in request, simplify client creation for resource calls and custom client (#51436)
* Remove cache, pass headers in request, simplify client creation

* Add test for http options creation
2022-07-04 11:18:45 +02:00

28 lines
874 B
Go

package buffered
import (
"testing"
"github.com/grafana/grafana-azure-sdk-go/azsettings"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/log/logtest"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/stretchr/testify/require"
)
func TestCreateTransportOptions(t *testing.T) {
t.Run("creates correct options object", func(t *testing.T) {
settings := backend.DataSourceInstanceSettings{
BasicAuthEnabled: false,
BasicAuthUser: "",
JSONData: []byte(`{"httpHeaderName1": "foo"}`),
DecryptedSecureJSONData: map[string]string{
"httpHeaderValue1": "bar",
},
}
opts, err := CreateTransportOptions(settings, &azsettings.AzureSettings{}, featuremgmt.WithFeatures(), &logtest.Fake{})
require.NoError(t, err)
require.Equal(t, map[string]string{"foo": "bar"}, opts.Headers)
})
}