當前位置: 首頁>>代碼示例>>Golang>>正文


Golang testutil.ExpectFailsRule函數代碼示例

本文整理匯總了Golang中github.com/graphql-go/graphql/testutil.ExpectFailsRule函數的典型用法代碼示例。如果您正苦於以下問題:Golang ExpectFailsRule函數的具體用法?Golang ExpectFailsRule怎麽用?Golang ExpectFailsRule使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ExpectFailsRule函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/graphql-go/graphql/testutil.ExpectFailsRule函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。