testing

package
v0.0.0-...-d5b48cf Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestCase

type TestCase struct {
	// Name is a descriptive name for this test suitable as a first argument to t.Run()
	Name string

	// InitialState is the list of objects that already exists when reconciliation
	// starts.
	InitialState []runtime.Object

	// ReconcileKey is the key of the object to reconcile in namespace/name form.
	ReconcileKey string

	// WantErr is true when we expect the Reconcile function to return an error.
	WantErr bool

	// WantErrMsg contains the pattern to match the returned error message.
	// Implies WantErr = true. TODO implement
	WantErrMsg string

	// WantResult is the reconcile result we expect to be returned from the
	// Reconcile function.
	WantResult reconcile.Result

	// WantPresent holds the non-exclusive set of objects we expect to exist
	// after reconciliation completes.
	WantPresent []runtime.Object

	// WantAbsent holds the list of objects expected to not exist
	// after reconciliation completes.
	WantAbsent []runtime.Object
}

TestCase holds a single row of our table test.

func (*TestCase) GetClient

func (tc *TestCase) GetClient() client.Client

GetClient returns the fake client to use for this test case.

func (*TestCase) Reconcile

func (tc *TestCase) Reconcile(r reconcile.Reconciler) (reconcile.Result, error)

Reconcile calls the given reconciler's Reconcile() function with the test case's reconcile request.

func (*TestCase) Runner

func (tc *TestCase) Runner(t *testing.T, r reconcile.Reconciler, c client.Client) func(t *testing.T)

Runner returns a testing func that can be passed to t.Run.

func (*TestCase) VerifyErr

func (tc *TestCase) VerifyErr(err error) error

VerifyErr verifies that the given error returned from Reconcile is the error expected by the test case.

func (*TestCase) VerifyResult

func (tc *TestCase) VerifyResult(result reconcile.Result) error

VerifyResult verifies that the given result returned from Reconcile is the result expected by the test case.

func (*TestCase) VerifyWantAbsent

func (tc *TestCase) VerifyWantAbsent(c client.Client) error

VerifyWantAbsent verifies that the client does not contain any of the objects expected to be absent after reconciliation.

func (*TestCase) VerifyWantPresent

func (tc *TestCase) VerifyWantPresent(c client.Client) error

VerifyWantPresent verifies that the client contains all the objects expected to be present after reconciliation.

Jump to

Keyboard shortcuts

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