-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit: 089caad3628e69003d79675558fe38023af02d31 [089caad] Parents: 9234c6da0e Author: Jan Jergus <[email protected]> Date: 18 February 2016 at 7:00:39 AM SGT Commit Date: 18 February 2016 at 8:47:14 AM SGT
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package graphql_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/graphql-go/graphql" | ||
"github.com/graphql-go/graphql/gqlerrors" | ||
"github.com/graphql-go/graphql/testutil" | ||
) | ||
|
||
func TestValidate_UniqueVariableNames_UniqueVariableNames(t *testing.T) { | ||
testutil.ExpectPassesRule(t, graphql.UniqueVariableNamesRule, ` | ||
query A($x: Int, $y: String) { __typename } | ||
query B($x: String, $y: Int) { __typename } | ||
`) | ||
} | ||
func TestValidate_UniqueVariableNames_DuplicateVariableNames(t *testing.T) { | ||
testutil.ExpectFailsRule(t, graphql.UniqueVariableNamesRule, ` | ||
query A($x: Int, $x: Int, $x: String) { __typename } | ||
query B($x: String, $x: Int) { __typename } | ||
query C($x: Int, $x: Int) { __typename } | ||
`, []gqlerrors.FormattedError{ | ||
testutil.RuleError(`There can only be one variable named "x".`, 2, 16, 2, 25), | ||
testutil.RuleError(`There can only be one variable named "x".`, 2, 16, 2, 34), | ||
testutil.RuleError(`There can only be one variable named "x".`, 3, 16, 3, 28), | ||
testutil.RuleError(`There can only be one variable named "x".`, 4, 16, 4, 25), | ||
}) | ||
} |