Documentation
¶
Overview ¶
Package coordinatorfake provides a configurable fake coordinator.Service for tests.
It lives in its own package (rather than internal/testutil) because it imports pkg/coordinator; keeping it separate avoids an import cycle for pkg/coordinator's own in-package tests, which depend on the base testutil fakes.
Index ¶
- type FakeCoordinator
- func (f *FakeCoordinator) ConsolidationCallCount() int
- func (f *FakeCoordinator) Process(transformation models.Transformation, direction coordinator.Direction)
- func (f *FakeCoordinator) ProcessCallCount() int
- func (f *FakeCoordinator) ProcessExternalScan(modelID, scanType string)
- func (f *FakeCoordinator) RunConsolidation(ctx context.Context)
- func (f *FakeCoordinator) Start(_ context.Context) error
- func (f *FakeCoordinator) Stop() error
- func (f *FakeCoordinator) TriggerBoundsRefresh(ctx context.Context, modelID string) error
- func (f *FakeCoordinator) TriggerScheduledRun(ctx context.Context, modelID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FakeCoordinator ¶
type FakeCoordinator struct {
ProcessCalls int
ConsolidationCalls int
StartErr error
StopErr error
// ProcessFn / ProcessExternalScanFn / RunConsolidationFn override the default behavior
// when set; the call counters are still incremented for Process and RunConsolidation.
ProcessFn func(transformation models.Transformation, direction coordinator.Direction)
ProcessExternalScanFn func(modelID, scanType string)
RunConsolidationFn func(ctx context.Context)
TriggerBoundsRefreshFn func(ctx context.Context, modelID string) error
TriggerScheduledRunFn func(ctx context.Context, modelID string) error
// contains filtered or unexported fields
}
FakeCoordinator is a configurable fake implementing coordinator.Service for tests.
The zero value is a no-op coordinator that counts Process and RunConsolidation calls. StartErr / StopErr are returned from Start / Stop. ProcessCalls and ConsolidationCalls are guarded by an internal mutex so they are safe to read from assertions after concurrent processing.
func (*FakeCoordinator) ConsolidationCallCount ¶
func (f *FakeCoordinator) ConsolidationCallCount() int
ConsolidationCallCount returns the number of RunConsolidation calls in a race-safe way.
func (*FakeCoordinator) Process ¶
func (f *FakeCoordinator) Process(transformation models.Transformation, direction coordinator.Direction)
Process increments ProcessCalls and invokes ProcessFn when set.
func (*FakeCoordinator) ProcessCallCount ¶
func (f *FakeCoordinator) ProcessCallCount() int
ProcessCallCount returns the number of Process calls in a race-safe way.
func (*FakeCoordinator) ProcessExternalScan ¶
func (f *FakeCoordinator) ProcessExternalScan(modelID, scanType string)
ProcessExternalScan invokes ProcessExternalScanFn when set, otherwise is a no-op.
func (*FakeCoordinator) RunConsolidation ¶
func (f *FakeCoordinator) RunConsolidation(ctx context.Context)
RunConsolidation increments ConsolidationCalls and invokes RunConsolidationFn when set.
func (*FakeCoordinator) Start ¶
func (f *FakeCoordinator) Start(_ context.Context) error
Start returns StartErr.
func (*FakeCoordinator) TriggerBoundsRefresh ¶
func (f *FakeCoordinator) TriggerBoundsRefresh(ctx context.Context, modelID string) error
TriggerBoundsRefresh returns nil by default.
func (*FakeCoordinator) TriggerScheduledRun ¶
func (f *FakeCoordinator) TriggerScheduledRun(ctx context.Context, modelID string) error
TriggerScheduledRun returns nil by default.