test

package
v0.0.0-...-56ff822 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteCmd

func ExecuteCmd(newCmd func(*factory.Factory) *cobra.Command, args []string, wantVariables map[string]interface{}) (string, error)

ExecuteCmd uses the passed in function to create a command and execute it

func LoadFixture

func LoadFixture(p ...string) ([]byte, error)

Load the given file from the fixtures directory

func NewFixture

func NewFixture(p ...string) func() ([]byte, error)

Load the fixture at the given location

func RunTests

func RunTests(t *testing.T, newCmd func(*factory.Factory) *cobra.Command, tests []TestCase)

RunTests is a helper function for table-driven tests using subtests

Types

type FakeGraphQLClient

type FakeGraphQLClient struct {
	// contains filtered or unexported fields
}

func (*FakeGraphQLClient) Query

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

type TestCase

type TestCase struct {
	// Name of the test case
	Name string

	// Environment variables to be set for the test case
	Env map[string]string

	// Arguments to be passed to the CLI app
	Args []string

	// Expected output from the CLI app
	WantText string

	// Function to load extected output
	WantFixture func() ([]byte, error)

	// Expect output to be written to this file
	WantFile string

	// Expected values for the GraphQL query variables
	WantVariables map[string]interface{}

	// Text expected in error. Empty string means no error expected.
	ErrContains string
}

Jump to

Keyboard shortcuts

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