本文整理汇总了Golang中github.com/graphql-go/graphql/testutil.ExpectFailsRule函数的典型用法代码示例。如果您正苦于以下问题:Golang ExpectFailsRule函数的具体用法?Golang ExpectFailsRule怎么用?Golang ExpectFailsRule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ExpectFailsRule函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDirectly
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDirectly(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Dog { ...fragA }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself.`, 2, 31),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:7,代码来源:rules_no_fragment_cycles_test.go
示例2: TestValidate_NoUndefinedVariables_VaMultipleUndefinedVariablesProduceMultipleErrors
func TestValidate_NoUndefinedVariables_VaMultipleUndefinedVariablesProduceMultipleErrors(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUndefinedVariablesRule, `
query Foo($b: String) {
...FragAB
}
query Bar($a: String) {
...FragAB
}
fragment FragAB on Type {
field1(a: $a, b: $b)
...FragC
field3(a: $a, b: $b)
}
fragment FragC on Type {
field2(c: $c)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Variable "$a" is not defined by operation "Foo".`, 9, 19, 2, 7),
testutil.RuleError(`Variable "$c" is not defined by operation "Foo".`, 14, 19, 2, 7),
testutil.RuleError(`Variable "$a" is not defined by operation "Foo".`, 11, 19, 2, 7),
testutil.RuleError(`Variable "$b" is not defined by operation "Bar".`, 9, 26, 5, 7),
testutil.RuleError(`Variable "$c" is not defined by operation "Bar".`, 14, 19, 5, 7),
testutil.RuleError(`Variable "$b" is not defined by operation "Bar".`, 11, 26, 5, 7),
})
}
开发者ID:trythings,项目名称:trythings,代码行数:25,代码来源:rules_no_undefined_variables_test.go
示例3: TestValidate_OverlappingFieldsCanBeMerged_VeryDeepConflict
func TestValidate_OverlappingFieldsCanBeMerged_VeryDeepConflict(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.OverlappingFieldsCanBeMergedRule, `
{
field {
deepField {
x: a
}
},
field {
deepField {
x: b
}
}
}
`, []gqlerrors.FormattedError{
testutil.RuleError(
`Fields "field" conflict because subfields "deepField" conflict because subfields "x" conflict because `+
`a and b are different fields.`,
3, 9,
4, 11,
5, 13,
8, 9,
9, 11,
10, 13),
})
}
开发者ID:trythings,项目名称:trythings,代码行数:26,代码来源:rules_overlapping_fields_can_be_merged_test.go
示例4: TestValidate_NoUnusedFragments_ContainsUnknownFragmentsWithRefCycle
func TestValidate_NoUnusedFragments_ContainsUnknownFragmentsWithRefCycle(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUnusedFragmentsRule, `
query Foo {
human(id: 4) {
...HumanFields1
}
}
query Bar {
human(id: 4) {
...HumanFields2
}
}
fragment HumanFields1 on Human {
name
...HumanFields3
}
fragment HumanFields2 on Human {
name
}
fragment HumanFields3 on Human {
name
}
fragment Unused1 on Human {
name
...Unused2
}
fragment Unused2 on Human {
name
...Unused1
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fragment "Unused1" is never used.`, 22, 7),
testutil.RuleError(`Fragment "Unused2" is never used.`, 26, 7),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:35,代码来源:rules_no_unused_fragments_test.go
示例5: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeply
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeply(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Dog { ...fragB }
fragment fragB on Dog { ...fragC }
fragment fragC on Dog { ...fragO }
fragment fragX on Dog { ...fragY }
fragment fragY on Dog { ...fragZ }
fragment fragZ on Dog { ...fragO }
fragment fragO on Dog { ...fragP }
fragment fragP on Dog { ...fragA, ...fragX }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself via fragB, fragC, fragO, fragP.`,
2, 31,
3, 31,
4, 31,
8, 31,
9, 31),
testutil.RuleError(`Cannot spread fragment "fragO" within itself via fragP, fragX, fragY, fragZ.`,
8, 31,
9, 41,
5, 31,
6, 31,
7, 31),
})
}
开发者ID:trythings,项目名称:trythings,代码行数:25,代码来源:rules_no_fragment_cycles_test.go
示例6: TestValidate_OverlappingFieldsCanBeMerged_ReportsDeepConflictToNearestCommonAncestor
func TestValidate_OverlappingFieldsCanBeMerged_ReportsDeepConflictToNearestCommonAncestor(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.OverlappingFieldsCanBeMergedRule, `
{
field {
deepField {
x: a
}
deepField {
x: b
}
},
field {
deepField {
y
}
}
}
`, []gqlerrors.FormattedError{
testutil.RuleError(
`Fields "deepField" conflict because subfields "x" conflict because `+
`a and b are different fields.`,
4, 11,
5, 13,
7, 11,
8, 13),
})
}
开发者ID:trythings,项目名称:trythings,代码行数:27,代码来源:rules_overlapping_fields_can_be_merged_test.go
示例7: TestValidate_NoCircularFragmentSpreads_SpreadingRecursivelyWithinFieldFails
func TestValidate_NoCircularFragmentSpreads_SpreadingRecursivelyWithinFieldFails(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragA on Human { relatives { ...fragA } },
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragA" within itself.`, 2, 45),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:7,代码来源:rules_no_fragment_cycles_test.go
示例8: TestValidate_OverlappingFieldsCanBeMerged_ReportsEachConflictOnce
func TestValidate_OverlappingFieldsCanBeMerged_ReportsEachConflictOnce(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.OverlappingFieldsCanBeMergedRule, `
{
f1 {
...A
...B
}
f2 {
...B
...A
}
f3 {
...A
...B
x: c
}
}
fragment A on Type {
x: a
}
fragment B on Type {
x: b
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fields "x" conflict because a and b are different fields.`, 18, 9, 21, 9),
testutil.RuleError(`Fields "x" conflict because a and c are different fields.`, 18, 9, 14, 11),
testutil.RuleError(`Fields "x" conflict because b and c are different fields.`, 21, 9, 14, 11),
})
}
开发者ID:trythings,项目名称:trythings,代码行数:29,代码来源:rules_overlapping_fields_can_be_merged_test.go
示例9: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfIndirectlyReportsOppositeOrder
func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfIndirectlyReportsOppositeOrder(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
fragment fragB on Dog { ...fragA }
fragment fragA on Dog { ...fragB }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Cannot spread fragment "fragB" within itself via fragA.`, 2, 31, 3, 31),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:8,代码来源:rules_no_fragment_cycles_test.go
示例10: TestValidate_PossibleFragmentSpreads_ObjectIntoNotContainingUnion
func TestValidate_PossibleFragmentSpreads_ObjectIntoNotContainingUnion(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.PossibleFragmentSpreadsRule, `
fragment invalidObjectWithinUnion on CatOrDog { ...humanFragment }
fragment humanFragment on Human { pets { name } }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fragment "humanFragment" cannot be spread here as objects of `+
`type "CatOrDog" can never be of type "Human".`, 2, 55),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_possible_fragment_spreads_test.go
示例11: TestValidate_PossibleFragmentSpreads_UnionIntoNotContainedObject
func TestValidate_PossibleFragmentSpreads_UnionIntoNotContainedObject(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.PossibleFragmentSpreadsRule, `
fragment invalidUnionWithinObject on Human { ...catOrDogFragment }
fragment catOrDogFragment on CatOrDog { __typename }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fragment "catOrDogFragment" cannot be spread here as objects of `+
`type "Human" can never be of type "CatOrDog".`, 2, 52),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_possible_fragment_spreads_test.go
示例12: TestValidate_KnownArgumentNames_InvalidArgName
func TestValidate_KnownArgumentNames_InvalidArgName(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
fragment invalidArgName on Dog {
doesKnowCommand(unknown: true)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".`, 3, 25),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_known_argument_names_test.go
示例13: TestValidate_NoUnusedVariables_VariableNotUsed
func TestValidate_NoUnusedVariables_VariableNotUsed(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUnusedVariablesRule, `
query ($a: String, $b: String, $c: String) {
field(a: $a, b: $b)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Variable "$c" is never used.`, 2, 38),
})
}
开发者ID:trythings,项目名称:trythings,代码行数:9,代码来源:rules_no_unused_variables_test.go
示例14: TestValidate_ScalarLeafs_ObjectTypeMissingSelection
func TestValidate_ScalarLeafs_ObjectTypeMissingSelection(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.ScalarLeafsRule, `
query directQueryOnObjectWithoutSubFields {
human
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Field "human" of type "Human" must have a sub selection.`, 3, 9),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_scalar_leafs_test.go
示例15: TestValidate_KnownArgumentNames_UndirectiveArgsAreInvalid
func TestValidate_KnownArgumentNames_UndirectiveArgsAreInvalid(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
{
dog @skip(unless: true)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Unknown argument "unless" on directive "@skip".`, 3, 19),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_known_argument_names_test.go
示例16: TestValidate_NoUndefinedVariables_VariableNotDefined
func TestValidate_NoUndefinedVariables_VariableNotDefined(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.NoUndefinedVariablesRule, `
query Foo($a: String, $b: String, $c: String) {
field(a: $a, b: $b, c: $c, d: $d)
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Variable "$d" is not defined by operation "Foo".`, 3, 39, 2, 7),
})
}
开发者ID:trythings,项目名称:trythings,代码行数:9,代码来源:rules_no_undefined_variables_test.go
示例17: TestValidate_ScalarLeafs_ScalarSelectionNotAllowedWithDirectivesAndArgs
func TestValidate_ScalarLeafs_ScalarSelectionNotAllowedWithDirectivesAndArgs(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.ScalarLeafsRule, `
fragment scalarSelectionsNotAllowedWithDirectivesAndArgs on Dog {
doesKnowCommand(dogCommand: SIT) @include(if: true) { sinceWhen }
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Field "doesKnowCommand" of type "Boolean" must not have a sub selection.`, 3, 61),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_scalar_leafs_test.go
示例18: TestValidate_PossibleFragmentSpreads_ObjectIntoNotImplementingInterface
func TestValidate_PossibleFragmentSpreads_ObjectIntoNotImplementingInterface(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.PossibleFragmentSpreadsRule, `
fragment invalidObjectWithinInterface on Pet { ...humanFragment }
fragment humanFragment on Human { pets { name } }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fragment "humanFragment" cannot be spread here as objects of `+
`type "Pet" can never be of type "Human".`, 2, 54),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_possible_fragment_spreads_test.go
示例19: TestValidate_ScalarLeafs_InterfaceTypeMissingSelection
func TestValidate_ScalarLeafs_InterfaceTypeMissingSelection(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.ScalarLeafsRule, `
{
human { pets }
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Field "pets" of type "[Pet]" must have a sub selection.`, 3, 17),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_scalar_leafs_test.go
示例20: TestValidate_PossibleFragmentSpreads_InterfaceIntoNonOverlappingUnion
func TestValidate_PossibleFragmentSpreads_InterfaceIntoNonOverlappingUnion(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.PossibleFragmentSpreadsRule, `
fragment invalidInterfaceWithinUnion on HumanOrAlien { ...petFragment }
fragment petFragment on Pet { name }
`, []gqlerrors.FormattedError{
testutil.RuleError(`Fragment "petFragment" cannot be spread here as objects of `+
`type "HumanOrAlien" can never be of type "Pet".`, 2, 62),
})
}
开发者ID:cerisier,项目名称:graphql,代码行数:9,代码来源:rules_possible_fragment_spreads_test.go
注:本文中的github.com/graphql-go/graphql/testutil.ExpectFailsRule函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论