From 718b47a75cf0e15c979c4d2105131fa99e8774f0 Mon Sep 17 00:00:00 2001 From: Kofo Okesola Date: Mon, 6 Nov 2023 14:03:00 +0100 Subject: [PATCH] fix mongo tests --- pumps/graph_mongo_test.go | 86 --------------------------------------- pumps/graph_sql_test.go | 5 --- pumps/mongo_test.go | 12 +++--- 3 files changed, 7 insertions(+), 96 deletions(-) diff --git a/pumps/graph_mongo_test.go b/pumps/graph_mongo_test.go index 2b0dbabf3..b258325a0 100644 --- a/pumps/graph_mongo_test.go +++ b/pumps/graph_mongo_test.go @@ -10,92 +10,6 @@ import ( "github.com/stretchr/testify/assert" ) -const rawGQLRequest = `POST / HTTP/1.1 -Host: localhost:8181 -User-Agent: PostmanRuntime/7.29.2 -Content-Length: 58 -Accept: */* -Accept-Encoding: gzip, deflate, br -Content-Type: application/json -Postman-Token: e6d4bc44-3268-40ae-888b-d84bb5ea07fd - -{"query":"{\n country(code: \"NGN\"){\n code\n }\n}"}` - -const rawGQLResponse = `HTTP/0.0 200 OK -Content-Length: 25 -Connection: close -Content-Type: application/json -X-Ratelimit-Limit: 0 -X-Ratelimit-Remaining: 0 -X-Ratelimit-Reset: 0 - -{"data":{"country":null}}` - -const schema = `type Query { - countries(filter: CountryFilterInput): [Country!]! - country(code: ID!): Country - continents(filter: ContinentFilterInput): [Continent!]! - continent(code: ID!): Continent - languages(filter: LanguageFilterInput): [Language!]! - language(code: ID!): Language -} - -type Country { - code: ID! - name: String! - native: String! - phone: String! - continent: Continent! - capital: String - currency: String - languages: [Language!]! - emoji: String! - emojiU: String! - states: [State!]! -} - -type Continent { - code: ID! - name: String! - countries: [Country!]! -} - -type Language { - code: ID! - name: String - native: String - rtl: Boolean! -} - -type State { - code: String - name: String! - country: Country! -} - -input StringQueryOperatorInput { - eq: String - ne: String - in: [String] - nin: [String] - regex: String - glob: String -} - -input CountryFilterInput { - code: StringQueryOperatorInput - currency: StringQueryOperatorInput - continent: StringQueryOperatorInput -} - -input ContinentFilterInput { - code: StringQueryOperatorInput -} - -input LanguageFilterInput { - code: StringQueryOperatorInput -}` - func TestGraphMongoPump_WriteData(t *testing.T) { conf := defaultConf() pump := GraphMongoPump{ diff --git a/pumps/graph_sql_test.go b/pumps/graph_sql_test.go index 8182e78c1..ea175a2e7 100644 --- a/pumps/graph_sql_test.go +++ b/pumps/graph_sql_test.go @@ -2,7 +2,6 @@ package pumps import ( "context" - "encoding/base64" "fmt" "os" "testing" @@ -113,10 +112,6 @@ func TestGraphSQLPump_Init(t *testing.T) { }) } -func convToBase64(raw string) string { - return base64.StdEncoding.EncodeToString([]byte(raw)) -} - func TestGraphSQLPump_WriteData(t *testing.T) { conf := GraphSQLConf{ SQLConf: SQLConf{ diff --git a/pumps/mongo_test.go b/pumps/mongo_test.go index 00a63a452..d0a0f888b 100644 --- a/pumps/mongo_test.go +++ b/pumps/mongo_test.go @@ -626,7 +626,7 @@ func TestMongoPump_WriteData(t *testing.T) { // ensure the length and content are the same assert.Equal(t, len(data), len(results)) - if diff := cmp.Diff(data, results, cmpopts.IgnoreFields(analytics.AnalyticsRecord{}, "id", "ApiSchema")); diff != "" { + if diff := cmp.Diff(data, results, cmpopts.IgnoreFields(analytics.AnalyticsRecord{}, "id", "ApiSchema", "GraphQLStats")); diff != "" { t.Error(diff) } } @@ -645,10 +645,12 @@ func TestMongoPump_WriteData(t *testing.T) { for i := range records { record := sampleRecord if i%2 == 0 { - record.RawRequest = rawGQLRequest - record.RawResponse = rawGQLResponse - record.ApiSchema = schema - record.Tags = []string{analytics.PredefinedTagGraphAnalytics} + record.GraphQLStats.IsGraphQL = true + record.GraphQLStats.Types = map[string][]string{ + "Country": {"code"}, + } + record.GraphQLStats.RootFields = []string{"country"} + record.GraphQLStats.HasErrors = false } records[i] = record }