testutil

package
v0.1.89 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RuntimeObjectIgnoreRvTypeMeta = cmp.Comparer(func(x, y runtime.Object) bool {
	xCopy := x.DeepCopyObject()
	yCopy := y.DeepCopyObject()
	CleanRVAndTypeMeta(xCopy)
	CleanRVAndTypeMeta(yCopy)
	return cmp.Diff(xCopy, yCopy) == ""
})

RuntimeObjectIgnoreRvTypeMeta compares two kubernetes objects, ignoring their resource version and TypeMeta. It is what you want 99% of the time.

Functions

func CleanRVAndTypeMeta

func CleanRVAndTypeMeta(r runtime.Object)

func CompareWithFixture

func CompareWithFixture(t *testing.T, output interface{}, opts ...option)

CompareWithFixture will compare output with a test fixture and allows to automatically update them by setting the UPDATE env var. If output is not a []byte or string, it will get serialized as yaml prior to the comparison. The fixtures are stored in $PWD/testdata/prefix${testName}.yaml

func FakeImageProvider added in v0.1.50

func FakeImageProvider(opts ...FakeImageProviderOpt) imageprovider.ReleaseImageProvider

func MarshalYamlAndDiff

func MarshalYamlAndDiff(a, b runtime.Object, t *testing.T) string

MarshalYamlAndDiff diffs the yaml representation of two runtime.Objects, useful for getting a human-readable diff for bigger objects.

func MatchExpected added in v0.1.29

func MatchExpected(expected any, opts ...cmp.Option) types.GomegaMatcher

MatchExpected ensures that `cmp.Diff(actual, expected)` returns nothing. Usage looks like:

Expect(actual).To(MatchExpected(expected))

func WithExtension added in v0.1.40

func WithExtension(extension string) option

func WithSubDir added in v0.1.49

func WithSubDir(subDir string) option

func WithSuffix added in v0.1.49

func WithSuffix(suffix string) option

Types

type FakeImageProviderOpt added in v0.1.76

type FakeImageProviderOpt func(*fakeImageProvider)

func WithComponentVersions added in v0.1.89

func WithComponentVersions(componentVersions map[string]string) FakeImageProviderOpt

WithComponentVersions sets the component versions the fake provider reports.

func WithImages added in v0.1.76

func WithImages(images map[string]string) FakeImageProviderOpt

func WithVersion added in v0.1.76

func WithVersion(version string) FakeImageProviderOpt

Jump to

Keyboard shortcuts

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