mock

package
v3.0.0-...-1e29e98 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphQLClientMock

type GraphQLClientMock struct {
	// QueryFunc mocks the Query method.
	QueryFunc func(ctx context.Context, query interface{}, vars map[string]interface{}) error
	// contains filtered or unexported fields
}

GraphQLClientMock is a mock implementation of GraphQLClient.

func TestSomethingThatUsesGraphQLClient(t *testing.T) {

	// make and configure a mocked GraphQLClient
	mockedGraphQLClient := &GraphQLClientMock{
		QueryFunc: func(ctx context.Context, query interface{}, vars map[string]interface{}) error {
			panic("mock out the Query method")
		},
	}

	// use mockedGraphQLClient in code that requires GraphQLClient
	// and then make assertions.

}

func (*GraphQLClientMock) Query

func (mock *GraphQLClientMock) Query(ctx context.Context, query interface{}, vars map[string]interface{}) error

Query calls QueryFunc.

func (*GraphQLClientMock) QueryCalls

func (mock *GraphQLClientMock) QueryCalls() []struct {
	Ctx   context.Context
	Query interface{}
	Vars  map[string]interface{}
}

QueryCalls gets all the calls that were made to Query. Check the length with:

len(mockedGraphQLClient.QueryCalls())

Jump to

Keyboard shortcuts

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