mock

package
v2.214.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 3 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 cantabular.GraphQLClient.

func TestSomethingThatUsesGraphQLClient(t *testing.T) {

	// make and configure a mocked cantabular.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 cantabular.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