From 392397473d46191f7ec9012d16e150008ded55a4 Mon Sep 17 00:00:00 2001 From: bzp2010 Date: Fri, 3 Sep 2021 02:31:37 +0800 Subject: [PATCH] fix: unit test --- api/internal/handler/schema/plugin_test.go | 2 +- .../handler/upstream/upstream_test.go | 168 +++++++++--------- 2 files changed, 85 insertions(+), 85 deletions(-) diff --git a/api/internal/handler/schema/plugin_test.go b/api/internal/handler/schema/plugin_test.go index d569f2d5d2..eb61e79394 100644 --- a/api/internal/handler/schema/plugin_test.go +++ b/api/internal/handler/schema/plugin_test.go @@ -62,5 +62,5 @@ func TestPlugin(t *testing.T) { // plugin type assert.ElementsMatch(t, []string{"basic-auth", "jwt-auth", "hmac-auth", "key-auth", "wolf-rbac"}, authPlugins) // consumer schema - assert.Equal(t, `{"additionalProperties":false,"properties":{"password":{"type":"string"},"username":{"type":"string"}},"required":["password","username"],"title":"work with consumer object","type":"object"}`, basicAuthConsumerSchema) + assert.Equal(t, `{"properties":{"password":{"type":"string"},"username":{"type":"string"}},"required":["password","username"],"title":"work with consumer object","type":"object"}`, basicAuthConsumerSchema) } diff --git a/api/internal/handler/upstream/upstream_test.go b/api/internal/handler/upstream/upstream_test.go index c2b274d4c8..47c219a4e5 100644 --- a/api/internal/handler/upstream/upstream_test.go +++ b/api/internal/handler/upstream/upstream_test.go @@ -55,10 +55,10 @@ func TestUpstream_Get(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -103,10 +103,10 @@ func TestUpstream_Get(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -345,10 +345,10 @@ func TestUpstream_Create(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -393,10 +393,10 @@ func TestUpstream_Create(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -441,10 +441,10 @@ func TestUpstream_Create(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -489,10 +489,10 @@ func TestUpstream_Create(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -542,10 +542,10 @@ func TestUpstream_Create(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -591,10 +591,10 @@ func TestUpstream_Create(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -689,10 +689,10 @@ func TestUpstream_Update(t *testing.T) { Upstream: entity.Upstream{ UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -738,10 +738,10 @@ func TestUpstream_Update(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -786,10 +786,10 @@ func TestUpstream_Update(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -834,10 +834,10 @@ func TestUpstream_Update(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -887,10 +887,10 @@ func TestUpstream_Update(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -973,10 +973,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": 15, - "send": 15, - "read": 15, + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -1022,10 +1022,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream2", - Timeout: map[string]interface{}{ - "connect": float64(20), - "send": float64(20), - "read": float64(20), + Timeout: &entity.Timeout{ + Connect: 20, + Send: 20, + Read: 20, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -1085,10 +1085,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream2", - Timeout: map[string]interface{}{ - "connect": float64(20), - "send": float64(20), - "read": float64(20), + Timeout: &entity.Timeout{ + Connect: 20, + Send: 20, + Read: 20, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -1138,10 +1138,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream2", - Timeout: map[string]interface{}{ - "connect": float64(20), - "send": float64(20), - "read": float64(20), + Timeout: &entity.Timeout{ + Connect: 20, + Send: 20, + Read: 20, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -1186,10 +1186,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream2", - Timeout: map[string]interface{}{ - "connect": float64(20), - "send": float64(20), - "read": float64(20), + Timeout: &entity.Timeout{ + Connect: 20, + Send: 20, + Read: 20, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -1243,10 +1243,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": float64(20), - "send": float64(20), - "read": float64(20), + Timeout: &entity.Timeout{ + Connect: 20, + Send: 20, + Read: 20, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -1291,10 +1291,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": float64(15), - "send": float64(15), - "read": float64(15), + Timeout: &entity.Timeout{ + Connect: 15, + Send: 15, + Read: 15, }, Checks: map[string]interface{}{ "active": map[string]interface{}{ @@ -1339,10 +1339,10 @@ func TestUpstream_Patch(t *testing.T) { }, UpstreamDef: entity.UpstreamDef{ Name: "upstream1", - Timeout: map[string]interface{}{ - "connect": float64(20), - "send": float64(20), - "read": float64(20), + Timeout: &entity.Timeout{ + Connect: 20, + Send: 20, + Read: 20, }, Checks: map[string]interface{}{ "active": map[string]interface{}{