Skip to content

Commit

Permalink
added test for int64 out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
JatinDev543 committed Feb 12, 2021
1 parent f73942d commit 3a9b1f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions validator/testdata/vars.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type Query {
optionalIntArg(i: Int): Boolean!
intArg(i: Int!): Boolean!
int64Arg(i: Int64!): Boolean!
stringArg(i: String): Boolean!
boolArg(i: Boolean!): Boolean!
floatArg(i: Float!): Boolean!
Expand All @@ -16,6 +17,8 @@ type Query {
typeArrayArg(i: [CustomType]): Boolean!
}

scalar Int64

input InputType {
name: String!
nullName: String
Expand Down
9 changes: 8 additions & 1 deletion validator/vars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,15 @@ func TestValidateVars(t *testing.T) {
})
require.EqualError(t, gerr, "input: variable.var Out of range value '2147483648', for type `Int`")
})
})

t.Run("out of range error for Int64", func(t *testing.T) {
q := gqlparser.MustLoadQuery(schema, `query foo($var: Int64!) { int64Arg(i: $var) }`)
_, gerr := validator.VariableValues(schema, q.Operations.ForName(""), map[string]interface{}{
"var": "9223372036854775808",
})
require.EqualError(t, gerr, "input: variable.var Out of range value '9223372036854775808', for type `Int64`")
})
})
t.Run("Int Array", func(t *testing.T) {
t.Run("Array with null", func(t *testing.T) {
q := gqlparser.MustLoadQuery(schema, `query foo($var: [Int]) { intArrayArg(i: $var) }`)
Expand Down

0 comments on commit 3a9b1f5

Please sign in to comment.