Ai
1 Star 0 Fork 0

麦冬果果/graphql-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rules_unique_variable_names_test.go 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
Hafiz Ismail 提交于 2016-04-06 21:43 +08:00 . Validate: Unique variable names
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),
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mdgg0816/graphql-go.git
git@gitee.com:mdgg0816/graphql-go.git
mdgg0816
graphql-go
graphql-go
v0.7.6

搜索帮助