Chore: use any rather than interface{} (#74066)

This commit is contained in:
Ryan McKinley
2023-08-30 08:46:47 -07:00
committed by GitHub
parent 3e272d2bda
commit 025b2f3011
525 changed files with 2528 additions and 2528 deletions

View File

@@ -13,26 +13,26 @@ import (
func TestAllowedCookies(t *testing.T) {
testCases := []struct {
desc string
given map[string]interface{}
given map[string]any
want []string
}{
{
desc: "Usual json data with keepCookies",
given: map[string]interface{}{
given: map[string]any{
"keepCookies": []string{"cookie2"},
},
want: []string{"cookie2"},
},
{
desc: "Usual json data without kepCookies",
given: map[string]interface{}{
given: map[string]any{
"something": "somethingelse",
},
want: []string(nil),
},
{
desc: "Usual json data that has multiple values in keepCookies",
given: map[string]interface{}{
given: map[string]any{
"keepCookies": []string{"cookie1", "cookie2", "special[]"},
},
want: []string{"cookie1", "cookie2", "special[]"},

View File

@@ -450,7 +450,7 @@ func (s *Service) httpClientOptions(ctx context.Context, ds *datasources.DataSou
if ds.JsonData != nil {
opts.CustomOptions = ds.JsonData.MustMap()
// allow the plugin sdk to get the json data in JSONDataFromHTTPClientOptions
deepJsonDataCopy := make(map[string]interface{}, len(opts.CustomOptions))
deepJsonDataCopy := make(map[string]any, len(opts.CustomOptions))
for k, v := range opts.CustomOptions {
deepJsonDataCopy[k] = v
}

View File

@@ -719,7 +719,7 @@ func TestService_GetHttpTransport(t *testing.T) {
t.Run("Should set custom headers if configured in JsonData", func(t *testing.T) {
provider := httpclient.NewProvider()
sjson := simplejson.NewFromAny(map[string]interface{}{
sjson := simplejson.NewFromAny(map[string]any{
"httpHeaderName1": "Authorization",
})
@@ -788,7 +788,7 @@ func TestService_GetHttpTransport(t *testing.T) {
t.Run("Should use request timeout if configured in JsonData", func(t *testing.T) {
provider := httpclient.NewProvider()
sjson := simplejson.NewFromAny(map[string]interface{}{
sjson := simplejson.NewFromAny(map[string]any{
"timeout": 19,
})
@@ -939,10 +939,10 @@ func TestService_getTimeout(t *testing.T) {
expectedTimeout time.Duration
}{
{jsonData: simplejson.New(), expectedTimeout: time.Minute},
{jsonData: simplejson.NewFromAny(map[string]interface{}{"timeout": nil}), expectedTimeout: time.Minute},
{jsonData: simplejson.NewFromAny(map[string]interface{}{"timeout": 0}), expectedTimeout: time.Minute},
{jsonData: simplejson.NewFromAny(map[string]interface{}{"timeout": 1}), expectedTimeout: time.Second},
{jsonData: simplejson.NewFromAny(map[string]interface{}{"timeout": "2"}), expectedTimeout: 2 * time.Second},
{jsonData: simplejson.NewFromAny(map[string]any{"timeout": nil}), expectedTimeout: time.Minute},
{jsonData: simplejson.NewFromAny(map[string]any{"timeout": 0}), expectedTimeout: time.Minute},
{jsonData: simplejson.NewFromAny(map[string]any{"timeout": 1}), expectedTimeout: time.Second},
{jsonData: simplejson.NewFromAny(map[string]any{"timeout": "2"}), expectedTimeout: 2 * time.Second},
}
sqlStore := db.InitTestDB(t)
@@ -1043,7 +1043,7 @@ func TestDataSource_CustomHeaders(t *testing.T) {
}{
{
name: "valid custom headers",
jsonData: simplejson.NewFromAny(map[string]interface{}{
jsonData: simplejson.NewFromAny(map[string]any{
"httpHeaderName1": "X-Test-Header1",
}),
secureJsonData: map[string][]byte{
@@ -1055,7 +1055,7 @@ func TestDataSource_CustomHeaders(t *testing.T) {
},
{
name: "missing header value",
jsonData: simplejson.NewFromAny(map[string]interface{}{
jsonData: simplejson.NewFromAny(map[string]any{
"httpHeaderName1": "X-Test-Header1",
}),
secureJsonData: map[string][]byte{},
@@ -1063,7 +1063,7 @@ func TestDataSource_CustomHeaders(t *testing.T) {
},
{
name: "non customer header value",
jsonData: simplejson.NewFromAny(map[string]interface{}{
jsonData: simplejson.NewFromAny(map[string]any{
"someotherheader": "X-Test-Header1",
}),
secureJsonData: map[string][]byte{},