Skip to content

Commit

Permalink
fix mongo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kofoworola committed Nov 6, 2023
1 parent 7e2bc77 commit 718b47a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 96 deletions.
86 changes: 0 additions & 86 deletions pumps/graph_mongo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
5 changes: 0 additions & 5 deletions pumps/graph_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package pumps

import (
"context"
"encoding/base64"
"fmt"
"os"
"testing"
Expand Down Expand Up @@ -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{
Expand Down
12 changes: 7 additions & 5 deletions pumps/mongo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand All @@ -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
}
Expand Down

0 comments on commit 718b47a

Please sign in to comment.