operatortest

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Suite

type Suite struct {
	suite.Suite

	NS      string
	Client  client.Client
	Config  *rest.Config
	Env     *envtest.Environment
	Logger  logr.Logger
	Context context.Context
	Scheme  *runtime.Scheme
}

Suite is the common test suite for integration tests using envtest. It's expected that concrete suites use this suite as the base.

func (*Suite) DeleteResources

func (ts *Suite) DeleteResources(resources ...client.Object)

DeleteResources deletes the given resources are updated from the suite. Each error will fail the test.

func (*Suite) EnsureNS

func (ts *Suite) EnsureNS(nsName string)

EnsureNS creates a new Namespace object using Suite.Client.

func (*Suite) EnsureResources

func (ts *Suite) EnsureResources(resources ...client.Object)

EnsureResources ensures that the given resources are existing in the suite. Each error will fail the test.

func (*Suite) FetchResource

func (ts *Suite) FetchResource(name types.NamespacedName, object client.Object)

FetchResource fetches the given object name and stores the result in the given object. Test fails on errors.

func (*Suite) FetchResources

func (ts *Suite) FetchResources(objectList client.ObjectList, opts ...client.ListOption)

FetchResources fetches resources and puts the items into the given list with the given list options. Test fails on errors.

func (*Suite) MapToRequest

func (ts *Suite) MapToRequest(object metav1.Object) ctrl.Request

MapToRequest maps the given object into a reconcile Request.

func (*Suite) NewNS

func (ts *Suite) NewNS(nsName string) *corev1.Namespace

NewNS returns a new Namespace object with the given name. Note: The namespace is not actually created, use EnsureNS for this.

func (*Suite) RegisterScheme

func (ts *Suite) RegisterScheme(addToScheme func(s *runtime.Scheme) error)

RegisterScheme passes the current scheme to the given SchemeBuilder func.

func (*Suite) SanitizeNameForNS

func (ts *Suite) SanitizeNameForNS(name string) string

SanitizeNameForNS first converts the given name to lowercase using strings.ToLower and then remove all characters but `a-z` (only lower case), `0-9` and the `-` (dash).

func (*Suite) SetupSuite

func (ts *Suite) SetupSuite()

SetupSuite implements suite.SetupAllSuite. It is run before running all the tests in the suite and is used to start up a local Kubernetes API server.

func (*Suite) TearDownSuite

func (ts *Suite) TearDownSuite()

TearDownSuite implements suite.TearDownAllSuite. It is used to shut down the local envtest environment.

func (*Suite) UpdateResources

func (ts *Suite) UpdateResources(resources ...client.Object)

UpdateResources ensures that the given resources are updated in the suite. Each error will fail the test.

func (*Suite) UpdateStatus

func (ts *Suite) UpdateStatus(resources ...client.Object)

UpdateStatus ensures that the Status property of the given resources are updated in the suite. Each error will fail the test.

Jump to

Keyboard shortcuts

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