testutil

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 14 Imported by: 108 modules, 106 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IntrospectionQuery = `` /* 1550-byte string literal not displayed */
View Source
var TestSchema *graphql.Schema

Functions

func ASTToJSON

func ASTToJSON(t *testing.T, a ast.Node) interface{}

func ContainSubset

func ContainSubset(super map[string]interface{}, sub map[string]interface{}) bool

func ContainSubsetSlice

func ContainSubsetSlice(super []interface{}, sub []interface{}) bool

func Diff

func Diff(want, got interface{}) []string

func EqualErrorMessage

func EqualErrorMessage(expected, result *graphql.Result, i int) bool

func EqualFormattedError added in v0.7.8

func EqualFormattedError(exp, act gqlerrors.FormattedError) bool

func EqualFormattedErrors added in v0.7.8

func EqualFormattedErrors(expected, actual []gqlerrors.FormattedError) bool

func EqualResults added in v0.7.8

func EqualResults(expected, result *graphql.Result) bool

func ExpectFailsRule

func ExpectFailsRule(t *testing.T, rule graphql.ValidationRuleFn, queryString string, expectedErrors []gqlerrors.FormattedError)

func ExpectFailsRuleWithSchema

func ExpectFailsRuleWithSchema(t *testing.T, schema *graphql.Schema, rule graphql.ValidationRuleFn, queryString string, expectedErrors []gqlerrors.FormattedError)

func ExpectPassesRule

func ExpectPassesRule(t *testing.T, rule graphql.ValidationRuleFn, queryString string)

func ExpectPassesRuleWithSchema

func ExpectPassesRuleWithSchema(t *testing.T, schema *graphql.Schema, rule graphql.ValidationRuleFn, queryString string)

func GetHero

func GetHero(episode interface{}) interface{}

func RuleError

func RuleError(message string, locs ...int) gqlerrors.FormattedError

func RunSubscribe added in v0.8.0

func RunSubscribe(t *testing.T, test *TestSubscription)

RunSubscribe runs a single GraphQL subscription test case.

func RunSubscribes added in v0.8.0

func RunSubscribes(t *testing.T, tests []*TestSubscription)

RunSubscribes runs the given GraphQL subscription test cases as subtests.

func TestExecute

func TestExecute(t *testing.T, ep graphql.ExecuteParams) *graphql.Result

func TestParse

func TestParse(t *testing.T, query string) *ast.Document

Types

type StarWarsChar

type StarWarsChar struct {
	ID              string
	Name            string
	Friends         []StarWarsChar
	AppearsIn       []int
	HomePlanet      string
	PrimaryFunction string
}
var (
	Luke           StarWarsChar
	Vader          StarWarsChar
	Han            StarWarsChar
	Leia           StarWarsChar
	Tarkin         StarWarsChar
	Threepio       StarWarsChar
	Artoo          StarWarsChar
	HumanData      map[int]StarWarsChar
	DroidData      map[int]StarWarsChar
	StarWarsSchema graphql.Schema
)

func GetDroid

func GetDroid(id int) StarWarsChar

func GetHuman

func GetHuman(id int) StarWarsChar

type TestResponse added in v0.8.0

type TestResponse struct {
	Data   string
	Errors []string
}

TestResponse models the expected response

type TestSubscription added in v0.8.0

type TestSubscription struct {
	Name            string
	Schema          graphql.Schema
	Query           string
	OperationName   string
	Variables       map[string]interface{}
	ExpectedResults []TestResponse
}

TestSubscription is a GraphQL test case to be used with RunSubscribe.

Jump to

Keyboard shortcuts

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