testutil

package
v0.0.0-...-32f7d7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2019 License: ISC, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsistOfGraphQLErrors

func ConsistOfGraphQLErrors(matchers ...interface{}) types.GomegaMatcher

ConsistOfGraphQLErrors is used to match a graphql.Errors like an array of graphql.Error's with Gomega's ConsistOf.

Expect(errs).Should(ConsistOfGraphQLErrors(
	MatchGraphQLError(
		MessageContainSubstring("First error"),
		KindIs(graphql.ErrKindSyntax),
	),
	MatchGraphQLError(
		MessageContainSubstring("Second error"),
	),
))

func MatchGraphQLError

func MatchGraphQLError(matchers ...ErrorFieldsMatcher) types.GomegaMatcher

MatchGraphQLError matches a graphql.Error with given fields.

The following example matches a graphql.Error including "Unterminated string" in the message and the error kind should match graphql.ErrKindSyntax.

Expect(err).Should(MatchGraphQLError(
	MessageContainSubstring("Unterminated string"),
	KindIs(graphql.ErrKindSyntax),
))

func SerializeToJSONAs

func SerializeToJSONAs(expected interface{}) types.GomegaMatcher

SerializeToJSONAs returns a Gomega matcher that first serializes actual value into JSON data format and then decodes the data into a variable that has the same type as the expected value and compare the decoded result against the expected value.

Types

type ErrorFieldsMatcher

type ErrorFieldsMatcher func(gstruct.Fields)

ErrorFieldsMatcher sets up fields to match.

func KindIs

func KindIs(errKind graphql.ErrKind) ErrorFieldsMatcher

KindIs matches the kind in the error to be the same as the given one.

func LocationEqual

func LocationEqual(location graphql.ErrorLocation) ErrorFieldsMatcher

LocationEqual matches the locations in the error to contain the only specified location.

func LocationsConsistOf

func LocationsConsistOf(locations []graphql.ErrorLocation) ErrorFieldsMatcher

LocationsConsistOf matches locations in the error to include all given locations.

func MessageContainSubstring

func MessageContainSubstring(s string) ErrorFieldsMatcher

MessageContainSubstring matches message in a graphql.Error to contain the specified string.

func MessageEqual

func MessageEqual(s string) ErrorFieldsMatcher

MessageEqual matches message in a graphql.Error to be the same as the specified string.

func OriginalErrorMatch

func OriginalErrorMatch(err interface{}) ErrorFieldsMatcher

OriginalErrorMatch matches original error with the given one using gomega.MatchError.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL