Documentation
¶
Overview ¶
Package testsupport provides shared fixtures for the domain, mediator, and cache layer unit tests: a scheme matching production's RegisterSchemes (internal/bootstrap/register.go), a fake controller-runtime client builder with status-subresource support, a no-op event recorder, and helpers for encoding a Go map into the runtime.RawExtension contract format every BlanketOps CR spec/status uses.
Index ¶
- func NewFakeClient(objs ...client.Object) client.Client
- func NewScheme() *runtime.Scheme
- func NoopRawRecorder() rawevents.EventRecorder
- func NoopRecorder() *events.EventRecorder
- func RawContract(m map[string]any) runtime.RawExtension
- type FakeExternalCache
- func (f *FakeExternalCache) Del(_ context.Context, key string) error
- func (f *FakeExternalCache) DelPrefix(_ context.Context, prefix string) error
- func (f *FakeExternalCache) Get(_ context.Context, key string, into any) (bool, error)
- func (f *FakeExternalCache) Set(_ context.Context, key string, val any, _ time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFakeClient ¶
NewFakeClient builds a fake controller-runtime client seeded with objs, with status-subresource tracking enabled for every BlanketOps CR type — required for r.Status().Update()/Patch() to behave like a real API server (otherwise status writes silently apply to the main object and status assertions pass for the wrong reason).
func NewScheme ¶
NewScheme mirrors internal/bootstrap/register.go's RegisterSchemes, plus the ExternalSecret and ProviderConfig GVKs the build/deployment/ githubevent/gitrepository/packages mediators create via unstructured.Unstructured.
func NoopRawRecorder ¶
func NoopRawRecorder() rawevents.EventRecorder
NoopRawRecorder returns a raw client-go events.EventRecorder that discards every call, for constructing mediators and build providers in tests.
func NoopRecorder ¶
func NoopRecorder() *events.EventRecorder
NoopRecorder returns an EventRecorder that safely discards every call — NewEventRecorder falls back to a no-op when given a type it doesn't recognize as either client-go recorder interface.
func RawContract ¶
func RawContract(m map[string]any) runtime.RawExtension
RawContract JSON-encodes m into a runtime.RawExtension, matching the spec.contract / status.contract field every BlanketOps CR uses instead of typed Kubernetes fields. Panics on marshal failure — the input is always a test-authored literal map, so a failure here is a test bug, not a runtime condition to handle gracefully.
Types ¶
type FakeExternalCache ¶
type FakeExternalCache struct {
// contains filtered or unexported fields
}
FakeExternalCache is an in-memory, JSON-serializing implementation of blanketops/environments' core/cache.ExternalCache, for testing this repo's internal/cache/* constructor wrappers. Values are marshaled on Set and unmarshaled on Get, matching how the real Redis/Memcached backends behave — a naive map[string]any passthrough would hide (de)serialization bugs. Mirrors the external library's own cache/internal/testutil fake, reimplemented here since that package is unexported outside its module.
func NewFakeExternalCache ¶
func NewFakeExternalCache() *FakeExternalCache
NewFakeExternalCache constructs an empty FakeExternalCache.
func (*FakeExternalCache) Del ¶
func (f *FakeExternalCache) Del(_ context.Context, key string) error
func (*FakeExternalCache) DelPrefix ¶
func (f *FakeExternalCache) DelPrefix(_ context.Context, prefix string) error