testutil

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const UpdateGoldenFiles bool = true

UpdateGoldenFiles defines whether or not to update the files locally after checking the responses for vailidity

Variables

View Source
var (
	// ErrTNil is returned by TestClient.Query(...) if the `testing.T` pointer in the TestClient is nil
	ErrTNil = errors.New("t is nil")
)

Functions

func CheckGoldenFramer

func CheckGoldenFramer(name string, f dfutil.Framer) error

CheckGoldenFramer checks the GoldenDataResponse and creates a standard file format for saving them

func EnsureKeyIsSet

func EnsureKeyIsSet(t *testing.T, m map[string]interface{}, key string)

EnsureKeyIsSet ensures that a single key is set in the map (m)

func EnsureKeysAreSet

func EnsureKeysAreSet(t *testing.T, m map[string]interface{}, keys ...string)

EnsureKeysAreSet ensures that all of the provided keys are set in the map (m)

func EnsureTypeEquality

func EnsureTypeEquality(t *testing.T, actual interface{}, expected interface{})

EnsureTypeEquality uses the test object and fails the test if the types are not equal

func GetTestQueryFunction

func GetTestQueryFunction(expected interface{}) func(*testing.T, interface{})

GetTestQueryFunction returns a function that satisfies the TestQuery function in the TestClient object

func GetTestVariablesFunction

func GetTestVariablesFunction(keys ...string) func(*testing.T, map[string]interface{})

GetTestVariablesFunction provides a function that satisfies the TestVariables function of a TestClient

func TypesAreEqual

func TypesAreEqual(a interface{}, b interface{}) bool

TypesAreEqual compares the types a and b. If they are not equal, then false is returned. If they are equal, then true is returned.

Types

type TestClient

type TestClient struct {
	T *testing.T
	// TestVariables can be used
	TestVariables func(t *testing.T, variables map[string]interface{})
	TestQuery     func(t *testing.T, q interface{})
}

The TestClient satisfies the Client interface and implements the query function

func NewTestClient

func NewTestClient(t *testing.T,
	testVariables func(t *testing.T, variables map[string]interface{}),
	testQuery func(t *testing.T, q interface{}),
) *TestClient

NewTestClient creates a new TestClient

func (*TestClient) Query

func (c *TestClient) Query(ctx context.Context, q interface{}, variables map[string]interface{}) error

Query calls the TestClient's caller-defined variables `TestVariables` and `TestQuery`

Jump to

Keyboard shortcuts

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