mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
c8c372c327
* remove dupe middleware * fix test
28 lines
771 B
Go
28 lines
771 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"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(context.Background(), settings, backend.NewLoggerWith("logger", "test"))
|
|
require.NoError(t, err)
|
|
require.Equal(t, http.Header{"Foo": []string{"bar"}}, opts.Header)
|
|
require.Equal(t, 1, len(opts.Middlewares))
|
|
})
|
|
}
|