test

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeMockGraphQLResponse

func EncodeMockGraphQLResponse(data any, err *graphql.Error) string

EncodeMockGraphQLResponse encodes data inputs to the graphql response payload

func NewMockGraphQLAffectedRowsResponse

func NewMockGraphQLAffectedRowsResponse(mutationName string, affectedRows int) string

NewMockGraphQLAffectedRowsResponse returns json response of a mutation response with affectedRows

func NewMockGraphQLClient

func NewMockGraphQLClient(responses []MockGraphQLResponse) *graphql.Client

NewMockGraphQLClient creates a mock graphql client of type HTTPClient where the mock Do() implementation returns the response and status code provided as params to the func.

func NewMockGraphQLClientQueries

func NewMockGraphQLClientQueries(responses map[string]string) *graphql.Client

NewMockGraphQLClientSingle creates a mock graphql client with response map Find responses by query string without validating variables

func NewMockGraphQLClientSingle

func NewMockGraphQLClientSingle(data any, err *graphql.Error) *graphql.Client

NewMockGraphQLClientSingle creates a mock graphql client with static response

Types

type MockDoType

type MockDoType func(req *http.Request) (*http.Response, error)

type MockGraphQLResponse

type MockGraphQLResponse struct {
	Request  graphql.GraphQLRequestPayload
	Response any
}

type MockHTTPClient

type MockHTTPClient struct {
	MockDo MockDoType
}

func NewMockHTTPClient

func NewMockHTTPClient(jsonResp string, statusCode int) *MockHTTPClient

NewMockHTTPClient creates a mock client of type HTTPClient where the mock Do() implementation returns the reponse and status code provided as params to the function.

func (*MockHTTPClient) Do

func (m *MockHTTPClient) Do(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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