testutil

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildChart

func BuildChart(opts ...ChartOption) *helmchart.Chart

BuildChart returns a Helm chart object built with basic data and any provided chart options.

func BuildRelease

func BuildRelease(mockOpts *helmrelease.MockReleaseOptions, opts ...ReleaseOption) *helmrelease.Release

BuildRelease builds a release with release.Mock using the given options, and applies any provided options to the release before returning it.

func Equal

func Equal(expected interface{}, options ...cmp.Option) types.GomegaMatcher

Equal uses go-cmp to compare actual with expected. Equal is strict about types when performing comparisons.

func MustParseHelmTime

func MustParseHelmTime(t string) helmtime.Time

MustParseHelmTime parses a string into a Helm time.Time, panicking if it fails.

func SaveChart

func SaveChart(c *chart.Chart, outDir string) (string, error)

SaveChart saves the given chart to the given directory, and returns the path to the saved chart. The chart is saved with a random suffix to avoid name collisions.

func SaveChartAsArtifact

func SaveChartAsArtifact(c *chart.Chart, algo digest.Algorithm, baseURL, outDir string) (*sourcev1.Artifact, error)

SaveChartAsArtifact saves the given chart to the given directory, and returns an artifact with the chart's metadata. The chart is saved with a random suffix to avoid name collisions.

Types

type ChartOption

type ChartOption func(*ChartOptions)

ChartOption is a function that can be used to modify a chart.

func ChartWithFailingHook

func ChartWithFailingHook() ChartOption

ChartWithFailingHook appends a failing hook to the chart.

func ChartWithFailingTestHook

func ChartWithFailingTestHook() ChartOption

ChartWithFailingTestHook appends a failing test hook to the chart.

func ChartWithName

func ChartWithName(name string) ChartOption

ChartWithName sets the name of the chart.

func ChartWithTestHook

func ChartWithTestHook() ChartOption

ChartWithTestHook appends a test hook to the chart.

func ChartWithVersion

func ChartWithVersion(version string) ChartOption

ChartWithVersion sets the version of the chart.

type ChartOptions

type ChartOptions struct {
	*helmchart.Chart
}

ChartOptions is a helper to build a Helm chart object.

type FakeRecorder

type FakeRecorder struct {
	Events        chan corev1.Event
	IncludeObject bool
}

FakeRecorder is used as a fake during tests.

It was invented to be used in tests which require more precise control over e.g. assertions of specific event fields like Reason. For which string comparisons on the concentrated event message using record.FakeRecorder is not sufficient.

To empty the Events channel into a slice of the recorded events, use GetEvents(). Not initializing Events will cause the recorder to not record any messages.

func NewFakeRecorder

func NewFakeRecorder(bufferSize int, includeObject bool) *FakeRecorder

NewFakeRecorder creates new fake event recorder with an Events channel with the given size. Setting includeObject to true will cause the recorder to include the object reference in the events.

To initialize a recorder which does not record any events, simply use:

recorder := new(FakeRecorder)

func (*FakeRecorder) AnnotatedEventf

func (f *FakeRecorder) AnnotatedEventf(obj runtime.Object, annotations map[string]string, eventType, reason, message string, args ...any)

AnnotatedEventf emits an event with annotations.

func (*FakeRecorder) Event

func (f *FakeRecorder) Event(obj runtime.Object, eventType, reason, message string)

Event emits an event with the given message.

func (*FakeRecorder) Eventf

func (f *FakeRecorder) Eventf(obj runtime.Object, eventType, reason, message string, args ...any)

Eventf emits an event with the given message.

func (*FakeRecorder) GetEvents

func (f *FakeRecorder) GetEvents() (events []corev1.Event)

GetEvents empties the Events channel and returns a slice of recorded events. If the Events channel is nil, it returns nil.

type ReleaseOption

type ReleaseOption func(*ReleaseOptions)

ReleaseOption is a function that can be used to modify a release.

func ReleaseWithConfig

func ReleaseWithConfig(config map[string]interface{}) ReleaseOption

ReleaseWithConfig sets the config on the release.

func ReleaseWithFailingHook

func ReleaseWithFailingHook() ReleaseOption

ReleaseWithFailingHook appends a failing hook to the release.

func ReleaseWithFailingTestHook

func ReleaseWithFailingTestHook() ReleaseOption

ReleaseWithFailingTestHook appends a failing test hook to the release.

func ReleaseWithHookExecution

func ReleaseWithHookExecution(name string, events []helmrelease.HookEvent, phase helmrelease.HookPhase) ReleaseOption

ReleaseWithHookExecution appends a hook with a last run with the given execution phase on the release.

func ReleaseWithHooks

func ReleaseWithHooks(hooks []*helmrelease.Hook) ReleaseOption

ReleaseWithHooks sets the hooks on the release.

func ReleaseWithLabels

func ReleaseWithLabels(labels map[string]string) ReleaseOption

ReleaseWithLabels sets the labels on the release.

func ReleaseWithTestHook

func ReleaseWithTestHook() ReleaseOption

ReleaseWithTestHook appends a test hook to the release.

type ReleaseOptions

type ReleaseOptions struct {
	*helmrelease.Release
}

ReleaseOptions is a helper to build a Helm release mock.

Jump to

Keyboard shortcuts

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