testutil

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 11 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 validity

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(t *testing.T, name string, f dfutil.Framer)

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) GetWorkflowUsage added in v1.4.7

func (c *TestClient) GetWorkflowUsage(ctx context.Context, owner, repo, workflow string, timeRange backend.TimeRange) (models.WorkflowUsage, error)

GetWorkflowUsage is not implemented because it is not being used at the moment.

func (*TestClient) ListWorkflows added in v1.4.7

func (c *TestClient) ListWorkflows(ctx context.Context, owner, repo string, opts *googlegithub.ListOptions) (*googlegithub.Workflows, *googlegithub.Response, error)

ListWorkflows is not implemented because it is not being used at the moment.

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