-
-
Save vladimiroff/d80d156917ff7868040b1e8f2db88fde to your computer and use it in GitHub Desktop.
Example usage of GraphQLTest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestFoo(t *testing.T) { | |
var env, cleanup = tEnv(t) | |
defer cleanup() | |
cases := []struct { | |
name string | |
ctx context.Context | |
query string | |
result string | |
errors []string | |
}{ | |
{ | |
name: "default", | |
ctx: userCtx, | |
query: loadTestData(t, "query_getFoo_request.graphql"), | |
result: loadTestData(t, "query_getFoo_response.json"), | |
}, | |
{ | |
name: "unauthorized", | |
ctx: guestCtx, | |
query: loadTestData(t, "query_getFoo_request.graphql"), | |
errors: []string{"unauthorized"}, | |
}, | |
} | |
for _, c := range cases { | |
t.Run(c.name, func(t *testing.T) { | |
GraphQLTest{ | |
Handler: env.schema, | |
Query: c.query, | |
Result: c.result, | |
Errors: c.errors, | |
Context: c.ctx, | |
}.Run(t) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment