Documentation
¶
Overview ¶
Package iactest provides shared fakes for tests that exercise the IaCProvider / ResourceDriver contract. Lifting these out of individual test files prevents the no-op-stub proliferation that otherwise occurs every time a new package needs to satisfy the interface (one no-op was already duplicated three times across this repo before consolidation).
The types here are deliberately minimal: each method returns a zero value or a caller-configured field. Tests that need richer behavior should compose these (embed the struct and override specific methods) rather than introducing a parallel implementation.
Index ¶
- type NoopDriver
- func (d *NoopDriver) Create(_ context.Context, _ interfaces.ResourceSpec) (*interfaces.ResourceOutput, error)
- func (d *NoopDriver) Delete(_ context.Context, _ interfaces.ResourceRef) error
- func (d *NoopDriver) Diff(_ context.Context, _ interfaces.ResourceSpec, _ *interfaces.ResourceOutput) (*interfaces.DiffResult, error)
- func (d *NoopDriver) HealthCheck(_ context.Context, _ interfaces.ResourceRef) (*interfaces.HealthResult, error)
- func (d *NoopDriver) Read(_ context.Context, _ interfaces.ResourceRef) (*interfaces.ResourceOutput, error)
- func (d *NoopDriver) Scale(_ context.Context, _ interfaces.ResourceRef, _ int) (*interfaces.ResourceOutput, error)
- func (d *NoopDriver) SensitiveKeys() []string
- func (d *NoopDriver) Update(_ context.Context, _ interfaces.ResourceRef, _ interfaces.ResourceSpec) (*interfaces.ResourceOutput, error)
- type NoopProvider
- func (p *NoopProvider) Apply(_ context.Context, _ *interfaces.IaCPlan) (*interfaces.ApplyResult, error)
- func (p *NoopProvider) BootstrapStateBackend(_ context.Context, _ map[string]any) (*interfaces.BootstrapResult, error)
- func (p *NoopProvider) Capabilities() []interfaces.IaCCapabilityDeclaration
- func (p *NoopProvider) Close() error
- func (p *NoopProvider) ComputePlanVersion() string
- func (p *NoopProvider) Destroy(_ context.Context, _ []interfaces.ResourceRef) (*interfaces.DestroyResult, error)
- func (p *NoopProvider) DetectDrift(_ context.Context, _ []interfaces.ResourceRef) ([]interfaces.DriftResult, error)
- func (p *NoopProvider) Import(_ context.Context, _ string, _ string) (*interfaces.ResourceState, error)
- func (p *NoopProvider) Initialize(_ context.Context, _ map[string]any) error
- func (p *NoopProvider) Name() string
- func (p *NoopProvider) Plan(_ context.Context, _ []interfaces.ResourceSpec, _ []interfaces.ResourceState) (*interfaces.IaCPlan, error)
- func (p *NoopProvider) ResolveSizing(_ string, _ interfaces.Size, _ *interfaces.ResourceHints) (*interfaces.ProviderSizing, error)
- func (p *NoopProvider) ResourceDriver(_ string) (interfaces.ResourceDriver, error)
- func (p *NoopProvider) Status(_ context.Context, _ []interfaces.ResourceRef) ([]interfaces.ResourceStatus, error)
- func (p *NoopProvider) SupportedCanonicalKeys() []string
- func (p *NoopProvider) Version() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NoopDriver ¶
type NoopDriver struct {
// DiffResult is returned from Diff(). When nil with DiffErr also nil,
// callers receive the plain (nil, nil) shape (treated by ComputePlan
// as "no changes — skip").
DiffResult *interfaces.DiffResult
// DiffErr is returned from Diff() when set; takes precedence over
// DiffResult.
DiffErr error
// DeleteErr is returned from Delete() when set. The default zero
// value (nil) makes Delete a no-op success — matching the rest of
// the NoopDriver shape.
DeleteErr error
// ReadResult is returned from Read(). When nil with ReadErr also
// nil, callers receive the plain (nil, nil) shape that pre-T7.5
// code expects from the Noop fake. Tests that exercise
// iac/refreshoutputs.Refresh set this to a *ResourceOutput whose
// Outputs map carries the live-shape keys the scenario asserts
// reconciliation for.
ReadResult *interfaces.ResourceOutput
// ReadErr is returned from Read() when set; takes precedence over
// ReadResult.
ReadErr error
// DiffCallCount is bumped on every Diff invocation. Exposed via
// atomic.Int64 so cache-hit tests under -race do not need separate
// synchronization.
DiffCallCount atomic.Int64
// DeleteCallCount is bumped on every Delete invocation. Exposed via
// atomic.Int64 so dispatch-coverage tests (e.g.,
// iac/conformance/scenarios_test.go) under -race can assert
// driver.Delete was invoked without separate synchronization.
DeleteCallCount atomic.Int64
// ReadCallCount is bumped on every Read invocation. Exposed via
// atomic.Int64 so refresh-outputs tests can assert driver.Read was
// dispatched without separate synchronization.
ReadCallCount atomic.Int64
}
NoopDriver is a minimal interfaces.ResourceDriver whose Diff method returns DiffResult (or DiffErr when set) and tracks call count so cache-hit tests can assert deduplication. Other lifecycle methods (Delete, Read) also bump per-method counters and accept a configured return value, so dispatch-coverage tests (notably iac/conformance/scenario_delete_action.go and iac/conformance/scenario_outputs_refresh.go) can pin driver-side invocation and observe live-shape reconciliation. Methods without an explicit counter return zero values.
func (*NoopDriver) Create ¶
func (d *NoopDriver) Create(_ context.Context, _ interfaces.ResourceSpec) (*interfaces.ResourceOutput, error)
Create returns (nil, nil).
func (*NoopDriver) Delete ¶
func (d *NoopDriver) Delete(_ context.Context, _ interfaces.ResourceRef) error
Delete bumps DeleteCallCount and returns DeleteErr (nil by default). The counter is the dispatch-coverage hook used by conformance scenarios that need to assert the v2 apply path actually reached driver.Delete (closing the latent gap from T3.3 where DOProvider's case-arm-less dispatch silently skipped Delete).
func (*NoopDriver) Diff ¶
func (d *NoopDriver) Diff(_ context.Context, _ interfaces.ResourceSpec, _ *interfaces.ResourceOutput) (*interfaces.DiffResult, error)
Diff bumps DiffCallCount and returns the configured DiffResult/DiffErr pair (DiffErr takes precedence when non-nil).
func (*NoopDriver) HealthCheck ¶
func (d *NoopDriver) HealthCheck(_ context.Context, _ interfaces.ResourceRef) (*interfaces.HealthResult, error)
HealthCheck returns (nil, nil).
func (*NoopDriver) Read ¶
func (d *NoopDriver) Read(_ context.Context, _ interfaces.ResourceRef) (*interfaces.ResourceOutput, error)
Read bumps ReadCallCount and returns the configured ReadResult/ ReadErr pair (ReadErr takes precedence when non-nil). The (nil, nil) shape is preserved when neither field is set, matching pre-T7.5 callers that only need the no-op signature.
func (*NoopDriver) Scale ¶
func (d *NoopDriver) Scale(_ context.Context, _ interfaces.ResourceRef, _ int) (*interfaces.ResourceOutput, error)
Scale returns (nil, nil).
func (*NoopDriver) SensitiveKeys ¶
func (d *NoopDriver) SensitiveKeys() []string
SensitiveKeys returns nil.
func (*NoopDriver) Update ¶
func (d *NoopDriver) Update(_ context.Context, _ interfaces.ResourceRef, _ interfaces.ResourceSpec) (*interfaces.ResourceOutput, error)
Update returns (nil, nil).
type NoopProvider ¶
type NoopProvider struct {
// Driver, when non-nil, is returned from ResourceDriver(typ) for
// every resource type. Leave nil for the pure-no-op shape used by
// callers that only need to satisfy the interface signature.
Driver *NoopDriver
// ProviderName overrides the Name() return value. Defaults to
// "iactest-noop" when empty.
ProviderName string
// ProviderVersion overrides the Version() return value. Defaults
// to "0.0.0-iactest" when empty.
ProviderVersion string
// DispatchVersion is the value returned from ComputePlanVersion(),
// satisfying iac/wfctlhelpers.ComputePlanVersionDeclarer. Tests
// driving the v2 apply path set this to "v2"; leaving it empty
// (the default) routes through the legacy v1 dispatch.
DispatchVersion string
}
NoopProvider is a minimal interfaces.IaCProvider whose every method returns the zero value (nil error, nil result). It satisfies the interface for compile-time checks and exists so callers do not need to hand-roll a 14-method shell every time they need a placeholder.
When a test needs to observe Diff dispatch or driver behavior, supply a non-nil Driver — ResourceDriver(typ) returns it for any resource type — and configure that driver's behavior via NoopDriver fields.
func (*NoopProvider) Apply ¶
func (p *NoopProvider) Apply(_ context.Context, _ *interfaces.IaCPlan) (*interfaces.ApplyResult, error)
Apply returns (nil, nil).
func (*NoopProvider) BootstrapStateBackend ¶
func (p *NoopProvider) BootstrapStateBackend(_ context.Context, _ map[string]any) (*interfaces.BootstrapResult, error)
BootstrapStateBackend returns (nil, nil).
func (*NoopProvider) Capabilities ¶
func (p *NoopProvider) Capabilities() []interfaces.IaCCapabilityDeclaration
Capabilities returns nil.
func (*NoopProvider) ComputePlanVersion ¶
func (p *NoopProvider) ComputePlanVersion() string
ComputePlanVersion satisfies iac/wfctlhelpers.ComputePlanVersionDeclarer. Returns DispatchVersion (which defaults to "" — treated as v1 by the dispatcher).
func (*NoopProvider) Destroy ¶
func (p *NoopProvider) Destroy(_ context.Context, _ []interfaces.ResourceRef) (*interfaces.DestroyResult, error)
Destroy returns (nil, nil).
func (*NoopProvider) DetectDrift ¶
func (p *NoopProvider) DetectDrift(_ context.Context, _ []interfaces.ResourceRef) ([]interfaces.DriftResult, error)
DetectDrift returns (nil, nil).
func (*NoopProvider) Import ¶
func (p *NoopProvider) Import(_ context.Context, _ string, _ string) (*interfaces.ResourceState, error)
Import returns (nil, nil).
func (*NoopProvider) Initialize ¶
Initialize is a no-op.
func (*NoopProvider) Name ¶
func (p *NoopProvider) Name() string
Name returns ProviderName when set, otherwise "iactest-noop".
func (*NoopProvider) Plan ¶
func (p *NoopProvider) Plan(_ context.Context, _ []interfaces.ResourceSpec, _ []interfaces.ResourceState) (*interfaces.IaCPlan, error)
Plan returns (nil, nil).
func (*NoopProvider) ResolveSizing ¶
func (p *NoopProvider) ResolveSizing(_ string, _ interfaces.Size, _ *interfaces.ResourceHints) (*interfaces.ProviderSizing, error)
ResolveSizing returns (nil, nil).
func (*NoopProvider) ResourceDriver ¶
func (p *NoopProvider) ResourceDriver(_ string) (interfaces.ResourceDriver, error)
ResourceDriver returns Driver (which may be nil — callers that dispatch Diff against the result must guard nil). Returning nil with no error matches the contract platform.ComputePlan tolerates: a missing driver for a resource type means the plan falls back to the legacy compare.
func (*NoopProvider) Status ¶
func (p *NoopProvider) Status(_ context.Context, _ []interfaces.ResourceRef) ([]interfaces.ResourceStatus, error)
Status returns (nil, nil).
func (*NoopProvider) SupportedCanonicalKeys ¶
func (p *NoopProvider) SupportedCanonicalKeys() []string
SupportedCanonicalKeys returns nil.
func (*NoopProvider) Version ¶
func (p *NoopProvider) Version() string
Version returns ProviderVersion when set, otherwise "0.0.0-iactest".