testutils

package module
v0.0.0-...-af0b63d Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

Copyright 2024 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupResources

func CleanupResources(g gomega.Gomega, ctx context.Context, cfg *rest.Config, k8sClient client.Client, namespace string, objs ...client.Object)

CleanupResources will clean up resources of the types of objects given in a particular namespace if given. The namespace will then be removed once it has been emptied. This utility is intended to be used in AfterEach blocks to clean up from a specific test. It calls various gomega assertions so will fail a test if there are any errors.

func MatchClusterOperatorStatusCondition

func MatchClusterOperatorStatusCondition(expected configv1.ClusterOperatorStatusCondition) types.GomegaMatcher

MatchClusterOperatorStatusCondition returns a custom matcher to check equality of configv1.ClusterOperatorStatusCondition.

func MatchClusterOperatorStatusConditions

func MatchClusterOperatorStatusConditions(expected []configv1.ClusterOperatorStatusCondition) types.GomegaMatcher

MatchClusterOperatorStatusConditions returns a custom matcher to check equality of configv1.ClusterOperatorStatusConditions.

func MatchCondition

func MatchCondition(expected metav1.Condition) types.GomegaMatcher

MatchCondition returns a custom matcher to check equality of metav1.Condition.

func MatchConditions

func MatchConditions(expected []metav1.Condition) types.GomegaMatcher

MatchConditions returns a custom matcher to check equality of a slice of metav1.Condtion.

func MatchViaJSON

func MatchViaJSON(expected interface{}) types.GomegaMatcher

MatchViaJSON returns a custom matcher to check equality of an object by converting it to JSON. Converting to JSON avoids the need to implement a custom matcher for each type. This is useful for comparing objects that are not directly comparable (maps may have differing orders).

Types

type LogEntry

type LogEntry struct {
	// Error is the error passed to an error log line.
	Error error

	// KeysAndValues are the keys and values that were logged with
	// the log line.
	KeysAndValues []interface{}

	// Level is the level of the info log line.
	Level int

	// Messages is the message from the log line.
	Message string
}

LogEntry captures the information about a particular log line.

type TestLogger

type TestLogger interface {
	Entries() []LogEntry
	Logger() logr.Logger
}

TestLogger provides a logr.Logger and access to a list of log entries logged via the logger.

func NewTestLogger

func NewTestLogger() TestLogger

NewTestLogger constructs a new TestLogger.

Directories

Path Synopsis
machine/v1
Linter warns about duplicated code with OpenStack, GCP, and Azure FailureDomains builders.
Linter warns about duplicated code with OpenStack, GCP, and Azure FailureDomains builders.

Jump to

Keyboard shortcuts

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