helpers

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GroupVersionKindV1 = schema.GroupVersionKind{
	Group:   "streaming.sneaksanddata.com",
	Version: "v1",
	Kind:    "MockStreamDefinition",
}
View Source
var GroupVersionKindV2 = schema.GroupVersionKind{
	Group:   "streaming.sneaksanddata.com",
	Version: "v2",
	Kind:    "MockStreamDefinition",
}

Functions

func AssertBackfillRequestCompleted

func AssertBackfillRequestCompleted(t *testing.T, k8sClient client.Client, objectName types.NamespacedName)

func AssertBackfillRequestNotCompleted

func AssertBackfillRequestNotCompleted(t *testing.T, k8sClient client.Client, objectName types.NamespacedName)

func AssertCronJobExists

func AssertCronJobExists(t *testing.T, k8sClient client.Client, name types.NamespacedName, additionalAssert func(*testing.T, *batchv1.CronJob))

func AssertCronJobNotExists

func AssertCronJobNotExists(t *testing.T, k8sClient client.Client, name types.NamespacedName)

func AssertEventRecorded added in v1.1.4

func AssertEventRecorded(t *testing.T, recorder *record.FakeRecorder, _ types.NamespacedName, additionalAssert func(*testing.T, string))

AssertEventRecorded drains all events currently buffered in the FakeRecorder and runs the provided assertion against each one. Each event has the format "<type> <reason> <message>" as produced by record.FakeRecorder. If additionalAssert is nil, only asserts that at least one event was recorded.

func AssertJobConfiguration

func AssertJobConfiguration(t *testing.T, k8sClient client.Client, name types.NamespacedName, expectedConfiguration string)

func AssertJobExists

func AssertJobExists(t *testing.T, k8sClient client.Client, name types.NamespacedName)

func AssertJobNotExists

func AssertJobNotExists(t *testing.T, k8sClient client.Client, name types.NamespacedName)

func AssertStreamDefinitionPhase

func AssertStreamDefinitionPhase(t *testing.T, k8sClient client.Client, name types.NamespacedName, phase stream.Phase)

func GetStreamDefinitionUnstructured

func GetStreamDefinitionUnstructured(ctx context.Context, k8sClient client.Client, name types.NamespacedName, gvk schema.GroupVersionKind) (*unstructured.Unstructured, error)

GetStreamDefinitionUnstructured reads the MockStreamDefinition identified by name from the provided client and returns it as an *unstructured.Unstructured.

func SetupClientFromBuilders

func SetupClientFromBuilders(builderV1 *mockv1.MockStreamDefinitionBuilder, builderV2 *v2.MockStreamDefinitionBuilder, resources *FakeClientResourcesBuilder) client.Client

SetupClientFromBuilders constructs a fake controller-runtime client seeded with the *testv1.MockStreamDefinition and/or *testv2.MockStreamDefinition produced by the provided builders.

Types

type FakeClientResourcesBuilder

type FakeClientResourcesBuilder struct {
	// contains filtered or unexported fields
}

FakeClientResourcesBuilder provides a fluent builder for accumulating secondary Kubernetes resources (Jobs, CronJobs, BackfillRequests, ...) that should be seeded into a controller-runtime fake client. The builder produces a single mutator function suitable for the addResources parameter of SetupClient / SetupClientFromBuilders.

func NewFakeClientResourcesBuilder

func NewFakeClientResourcesBuilder() *FakeClientResourcesBuilder

NewFakeClientResourcesBuilder creates an empty FakeClientResourcesBuilder.

func (*FakeClientResourcesBuilder) Apply

Apply appends an arbitrary mutator function to the builder. This allows composing the builder with existing functional-option style helpers.

func (*FakeClientResourcesBuilder) Build

Build returns a single mutator function that applies all accumulated resources to a *crfake.ClientBuilder. The result is computed on the first call and the same function value is returned on subsequent calls.

func (*FakeClientResourcesBuilder) WithBackfillRequest

WithBackfillRequest seeds the fake client with a BackfillRequest named "backfill1" targeting the MockStreamDefinition identified by n.

func (*FakeClientResourcesBuilder) WithCompletedJob

WithCompletedJob seeds the fake client with a batch Job in a completed state.

func (*FakeClientResourcesBuilder) WithConsistentCronJob

WithConsistentCronJob seeds the fake client with a CronJob whose configuration-hash annotation matches the provided hash.

func (*FakeClientResourcesBuilder) WithConsistentJob

WithConsistentJob seeds the fake client with a batch Job whose configuration-hash annotation matches the provided hash.

func (*FakeClientResourcesBuilder) WithFailedJob

WithFailedJob seeds the fake client with a batch Job in a failed state (failed twice with backoffLimit = 1).

func (*FakeClientResourcesBuilder) WithOutdatedCronJob

WithOutdatedCronJob seeds the fake client with a CronJob whose configuration-hash annotation is set to "old-hash".

func (*FakeClientResourcesBuilder) WithOutdatedJob

WithOutdatedJob seeds the fake client with a batch Job whose configuration-hash annotation is set to "old-hash".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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