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


Golang testutil.RuleError函數代碼示例

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


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

示例1: 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:housinganywhere,項目名稱:graphql,代碼行數:29,代碼來源:rules_overlapping_fields_can_be_merged_test.go

示例2: 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:housinganywhere,項目名稱:graphql,代碼行數:35,代碼來源:rules_no_unused_fragments_test.go

示例3: 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:housinganywhere,項目名稱:graphql,代碼行數:25,代碼來源:rules_no_fragment_cycles_test.go

示例4: TestValidate_UniqueInputFieldNames_ManyDuplicateInputObjectFields

func TestValidate_UniqueInputFieldNames_ManyDuplicateInputObjectFields(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.UniqueInputFieldNamesRule, `
      {
        field(arg: { f1: "value", f1: "value", f1: "value" })
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`There can be only one input field named "f1".`, 3, 22, 3, 35),
		testutil.RuleError(`There can be only one input field named "f1".`, 3, 22, 3, 48),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:10,代碼來源:rules_unique_input_field_names_test.go

示例5: TestValidate_NoUnusedVariables_MultipleVariablesNotUsed

func TestValidate_NoUnusedVariables_MultipleVariablesNotUsed(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.NoUnusedVariablesRule, `
      query Foo($a: String, $b: String, $c: String) {
        field(b: $b)
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Variable "$a" is never used in operation "Foo".`, 2, 17),
		testutil.RuleError(`Variable "$c" is never used in operation "Foo".`, 2, 41),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:10,代碼來源:rules_no_unused_variables_test.go

示例6: TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgs

func TestValidate_KnownArgumentNames_UnknownArgsAmongstKnownArgs(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.KnownArgumentNamesRule, `
      fragment oneGoodArgOneInvalidArg on Dog {
        doesKnowCommand(whoknows: 1, dogCommand: SIT, unknown: true)
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Unknown argument "whoknows" on field "doesKnowCommand" of type "Dog".`, 3, 25),
		testutil.RuleError(`Unknown argument "unknown" on field "doesKnowCommand" of type "Dog".`, 3, 55),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:10,代碼來源:rules_known_argument_names_test.go

示例7: TestValidate_UniqueArgumentNames_ManyDuplicateFieldArguments

func TestValidate_UniqueArgumentNames_ManyDuplicateFieldArguments(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.UniqueArgumentNamesRule, `
      {
        field(arg1: "value", arg1: "value", arg1: "value")
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`There can be only one argument named "arg1".`, 3, 15, 3, 30),
		testutil.RuleError(`There can be only one argument named "arg1".`, 3, 15, 3, 45),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:10,代碼來源:rules_unique_argument_names_test.go

示例8: TestValidate_NoUndefinedVariables_MultipleVariablesNotDefined

func TestValidate_NoUndefinedVariables_MultipleVariablesNotDefined(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.NoUndefinedVariablesRule, `
      query Foo($b: String) {
        field(a: $a, b: $b, c: $c)
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Variable "$a" is not defined by operation "Foo".`, 3, 18, 2, 7),
		testutil.RuleError(`Variable "$c" is not defined by operation "Foo".`, 3, 32, 2, 7),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:10,代碼來源:rules_no_undefined_variables_test.go

示例9: TestValidate_VariablesAreInputTypes_1

func TestValidate_VariablesAreInputTypes_1(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.VariablesAreInputTypesRule, `
      query Foo($a: Dog, $b: [[CatOrDog!]]!, $c: Pet) {
        field(a: $a, b: $b, c: $c)
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Variable "$a" cannot be non-input type "Dog".`, 2, 21),
		testutil.RuleError(`Variable "$b" cannot be non-input type "[[CatOrDog!]]!".`, 2, 30),
		testutil.RuleError(`Variable "$c" cannot be non-input type "Pet".`, 2, 50),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:11,代碼來源:rules_variables_are_input_types_test.go

示例10: TestValidate_KnownDirectives_WithMisplacedDirectives

func TestValidate_KnownDirectives_WithMisplacedDirectives(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.KnownDirectivesRule, `
      query Foo @include(if: true) {
        name @operationOnly
        ...Frag @operationOnly
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Directive "include" may not be used on QUERY.`, 2, 17),
		testutil.RuleError(`Directive "operationOnly" may not be used on FIELD.`, 3, 14),
		testutil.RuleError(`Directive "operationOnly" may not be used on FRAGMENT_SPREAD.`, 4, 17),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:12,代碼來源:rules_known_directives_rule_test.go

示例11: TestValidate_ProvidedNonNullArguments_DirectiveArguments_WithDirectiveWithMissingTypes

func TestValidate_ProvidedNonNullArguments_DirectiveArguments_WithDirectiveWithMissingTypes(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.ProvidedNonNullArgumentsRule, `
        {
          dog @include {
            name @skip
          }
        }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Directive "@include" argument "if" of type "Boolean!" is required but not provided.`, 3, 15),
		testutil.RuleError(`Directive "@skip" argument "if" of type "Boolean!" is required but not provided.`, 4, 18),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:12,代碼來源:rules_provided_non_null_arguments_test.go

示例12: TestValidate_ProvidedNonNullArguments_InvalidNonNullableValue_MissingMultipleNonNullableArguments

func TestValidate_ProvidedNonNullArguments_InvalidNonNullableValue_MissingMultipleNonNullableArguments(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.ProvidedNonNullArgumentsRule, `
        {
          complicatedArgs {
            multipleReqs
          }
        }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Field "multipleReqs" argument "req1" of type "Int!" is required but not provided.`, 4, 13),
		testutil.RuleError(`Field "multipleReqs" argument "req2" of type "Int!" is required but not provided.`, 4, 13),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:12,代碼來源:rules_provided_non_null_arguments_test.go

示例13: TestValidate_UniqueVariableNames_DuplicateVariableNames

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),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:12,代碼來源:rules_unique_variable_names_test.go

示例14: TestValidate_AnonymousOperationMustBeAlone_MultipleAnonOperations

func TestValidate_AnonymousOperationMustBeAlone_MultipleAnonOperations(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.LoneAnonymousOperationRule, `
      {
        fieldA
      }
      {
        fieldB
      }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`This anonymous operation must be the only defined operation.`, 2, 7),
		testutil.RuleError(`This anonymous operation must be the only defined operation.`, 5, 7),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:13,代碼來源:rules_lone_anonymous_operation_rule_test.go

示例15: TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeplyTwoPaths_AltTraverseOrder

func TestValidate_NoCircularFragmentSpreads_NoSpreadingItselfDeeplyTwoPaths_AltTraverseOrder(t *testing.T) {
	testutil.ExpectFailsRule(t, graphql.NoFragmentCyclesRule, `
      fragment fragA on Dog { ...fragC }
      fragment fragB on Dog { ...fragC }
      fragment fragC on Dog { ...fragA, ...fragB }
    `, []gqlerrors.FormattedError{
		testutil.RuleError(`Cannot spread fragment "fragA" within itself via fragC.`,
			2, 31,
			4, 31),
		testutil.RuleError(`Cannot spread fragment "fragC" within itself via fragB.`,
			4, 41,
			3, 31),
	})
}
開發者ID:housinganywhere,項目名稱:graphql,代碼行數:14,代碼來源:rules_no_fragment_cycles_test.go


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