testutils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDependencies

func CopyDependencies(deps *typesv1.Dependencies) *typesv1.Dependencies

func NewMemoryStateContainer

func NewMemoryStateContainer() state.Container

func NewMockBlueprintLoader

func NewMockBlueprintLoader(
	stubDiagnostics []*core.Diagnostic,
	clock commoncore.Clock,
	instances state.InstancesContainer,
	deployEventSequence []container.DeployEvent,
	changeStagingEventSequence []ChangeStagingEvent,
	opts ...MockBlueprintLoaderOption,
) container.Loader

func NewMockBlueprintValidationStore

func NewMockBlueprintValidationStore(
	validations map[string]*manage.BlueprintValidation,
) manage.Validation

func NewMockChangesetStore

func NewMockChangesetStore(
	validations map[string]*manage.Changeset,
) manage.Changesets

func NewMockCleanupOperationsStore added in v0.3.0

func NewMockCleanupOperationsStore(
	operations map[string]*manage.CleanupOperation,
) manage.CleanupOperations

NewMockCleanupOperationsStore creates a new mock cleanup operations store.

func NewMockEventStore

func NewMockEventStore(
	events map[string]*manage.Event,
) manage.Events

func NewMockReconciliationResultsStore added in v0.2.0

func NewMockReconciliationResultsStore(
	results map[string]*manage.ReconciliationResult,
) manage.ReconciliationResults

NewMockReconciliationResultsStore creates a new mock reconciliation results store.

func SSEToManageEvent

func SSEToManageEvent(
	event *sse.Event,
) *manage.Event

Types

type ChangeStagingEvent

type ChangeStagingEvent struct {
	ResourceChangesEvent  *container.ResourceChangesMessage
	ChildChangesEvent     *container.ChildChangesMessage
	LinkChangesEvent      *container.LinkChangesMessage
	FinalBlueprintChanges *changes.BlueprintChanges
	DriftDetectedEvent    *DriftDetectedEventData
	Error                 error
}

type DeployEventWrapper

type DeployEventWrapper struct {
	DeployEvent *container.DeployEvent
	DeployError error
}

type DeployTracker added in v0.2.0

type DeployTracker struct {

	// DeployCalls contains all the deploy inputs that were passed to the Deploy method.
	DeployCalls []*container.DeployInput
	// contains filtered or unexported fields
}

DeployTracker tracks calls to the Deploy method for testing.

func NewDeployTracker added in v0.2.0

func NewDeployTracker() *DeployTracker

NewDeployTracker creates a new DeployTracker.

func (*DeployTracker) GetRollbackDeployCalls added in v0.2.0

func (t *DeployTracker) GetRollbackDeployCalls() []*container.DeployInput

GetRollbackDeployCalls returns only the deploy calls that were made as rollback operations.

func (*DeployTracker) RecordCall added in v0.2.0

func (t *DeployTracker) RecordCall(input *container.DeployInput)

RecordCall records a deploy call.

func (*DeployTracker) WasDeployCalled added in v0.2.0

func (t *DeployTracker) WasDeployCalled() bool

WasDeployCalled returns true if Deploy was called at least once.

type DestroyTracker added in v0.2.0

type DestroyTracker struct {

	// DestroyCalls contains all the destroy inputs that were passed to the Destroy method.
	DestroyCalls []*container.DestroyInput
	// contains filtered or unexported fields
}

DestroyTracker tracks calls to the Destroy method for testing.

func NewDestroyTracker added in v0.2.0

func NewDestroyTracker() *DestroyTracker

NewDestroyTracker creates a new DestroyTracker.

func (*DestroyTracker) GetRollbackCalls added in v0.2.0

func (t *DestroyTracker) GetRollbackCalls() []*container.DestroyInput

GetRollbackCalls returns only the destroy calls that were made as rollback operations.

func (*DestroyTracker) RecordCall added in v0.2.0

func (t *DestroyTracker) RecordCall(input *container.DestroyInput)

RecordCall records a destroy call.

func (*DestroyTracker) WasDestroyCalled added in v0.2.0

func (t *DestroyTracker) WasDestroyCalled() bool

WasDestroyCalled returns true if Destroy was called at least once.

type DriftDetectedEventData added in v0.2.0

type DriftDetectedEventData struct {
	Message              string                               `json:"message"`
	ReconciliationResult *container.ReconciliationCheckResult `json:"reconciliationResult"`
	Timestamp            int64                                `json:"timestamp"`
}

DriftDetectedEventData represents the data from a drift detected event.

type FailingIDGenerator

type FailingIDGenerator struct{}

func (*FailingIDGenerator) GenerateID

func (f *FailingIDGenerator) GenerateID() (string, error)

type MemoryStateContainer

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

func (*MemoryStateContainer) Children

func (*MemoryStateContainer) Exports

func (*MemoryStateContainer) Instances

func (*MemoryStateContainer) Metadata

func (*MemoryStateContainer) Resources

type MockBlueprintContainer

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

func (*MockBlueprintContainer) ApplyReconciliation added in v0.2.0

func (*MockBlueprintContainer) BlueprintSpec

func (m *MockBlueprintContainer) BlueprintSpec() speccore.BlueprintSpec

func (*MockBlueprintContainer) CheckReconciliation added in v0.2.0

func (*MockBlueprintContainer) Deploy

func (m *MockBlueprintContainer) Deploy(
	ctx context.Context,
	input *container.DeployInput,
	channels *container.DeployChannels,
	paramOverrides core.BlueprintParams,
) error

func (*MockBlueprintContainer) Destroy

func (m *MockBlueprintContainer) Destroy(
	ctx context.Context,
	input *container.DestroyInput,
	channels *container.DeployChannels,
	paramOverrides core.BlueprintParams,
)

func (*MockBlueprintContainer) Diagnostics

func (m *MockBlueprintContainer) Diagnostics() []*core.Diagnostic

func (*MockBlueprintContainer) RefChainCollector

func (m *MockBlueprintContainer) RefChainCollector() refgraph.RefChainCollector

func (*MockBlueprintContainer) ResourceTemplates

func (m *MockBlueprintContainer) ResourceTemplates() map[string]string

func (*MockBlueprintContainer) SpecLinkInfo

func (m *MockBlueprintContainer) SpecLinkInfo() links.SpecLinkInfo

func (*MockBlueprintContainer) StageChanges

type MockBlueprintLoader

type MockBlueprintLoader struct {

	// DestroyTracker tracks calls to the Destroy method for testing auto-rollback.
	DestroyTracker *DestroyTracker
	// DeployTracker tracks calls to the Deploy method for testing update rollback.
	DeployTracker *DeployTracker

	// ReconciliationTracker tracks calls to CheckReconciliation and ApplyReconciliation.
	ReconciliationTracker *ReconciliationTracker
	// contains filtered or unexported fields
}

func (*MockBlueprintLoader) Load

func (m *MockBlueprintLoader) Load(
	ctx context.Context,
	blueprintSpecFile string,
	params core.BlueprintParams,
) (container.BlueprintContainer, error)

func (*MockBlueprintLoader) LoadFromSchema

func (m *MockBlueprintLoader) LoadFromSchema(
	ctx context.Context,
	blueprintSchema *schema.Blueprint,
	params core.BlueprintParams,
) (container.BlueprintContainer, error)

func (*MockBlueprintLoader) LoadString

func (m *MockBlueprintLoader) LoadString(
	ctx context.Context,
	blueprintSpec string,
	inputFormat schema.SpecFormat,
	params core.BlueprintParams,
) (container.BlueprintContainer, error)

func (*MockBlueprintLoader) Validate

func (m *MockBlueprintLoader) Validate(
	ctx context.Context,
	blueprintSpecFile string,
	params core.BlueprintParams,
) (*container.ValidationResult, error)

func (*MockBlueprintLoader) ValidateFromSchema

func (m *MockBlueprintLoader) ValidateFromSchema(
	ctx context.Context,
	blueprintSchema *schema.Blueprint,
	params core.BlueprintParams,
) (*container.ValidationResult, error)

func (*MockBlueprintLoader) ValidateString

func (m *MockBlueprintLoader) ValidateString(
	ctx context.Context,
	blueprintSpec string,
	inputFormat schema.SpecFormat,
	params core.BlueprintParams,
) (*container.ValidationResult, error)

type MockBlueprintLoaderOption

type MockBlueprintLoaderOption func(*MockBlueprintLoader)

func WithApplyReconciliationError added in v0.2.0

func WithApplyReconciliationError(err error) MockBlueprintLoaderOption

WithApplyReconciliationError configures an error to return from ApplyReconciliation.

func WithApplyReconciliationResult added in v0.2.0

func WithApplyReconciliationResult(result *container.ApplyReconciliationResult) MockBlueprintLoaderOption

WithApplyReconciliationResult configures the result to return from ApplyReconciliation.

func WithCheckReconciliationError added in v0.2.0

func WithCheckReconciliationError(err error) MockBlueprintLoaderOption

WithCheckReconciliationError configures an error to return from CheckReconciliation.

func WithCheckReconciliationResult added in v0.2.0

func WithCheckReconciliationResult(result *container.ReconciliationCheckResult) MockBlueprintLoaderOption

WithCheckReconciliationResult configures the result to return from CheckReconciliation.

func WithDeployTracker added in v0.2.0

func WithDeployTracker(tracker *DeployTracker) MockBlueprintLoaderOption

WithDeployTracker configures a DeployTracker to track deploy calls.

func WithDestroyEventSequence added in v0.2.0

func WithDestroyEventSequence(events []container.DeployEvent) MockBlueprintLoaderOption

WithDestroyEventSequence configures the event sequence for destroy operations.

func WithDestroyTracker added in v0.2.0

func WithDestroyTracker(tracker *DestroyTracker) MockBlueprintLoaderOption

WithDestroyTracker configures a DestroyTracker to track destroy calls.

func WithMockBlueprintLoaderChangeStagingError

func WithMockBlueprintLoaderChangeStagingError(err error) MockBlueprintLoaderOption

func WithMockBlueprintLoaderDeployError

func WithMockBlueprintLoaderDeployError(err error) MockBlueprintLoaderOption

func WithReconciliationTracker added in v0.2.0

func WithReconciliationTracker(tracker *ReconciliationTracker) MockBlueprintLoaderOption

WithReconciliationTracker configures a ReconciliationTracker to track reconciliation calls.

func WithRollbackDeployEventSequence added in v0.2.0

func WithRollbackDeployEventSequence(events []container.DeployEvent) MockBlueprintLoaderOption

WithRollbackDeployEventSequence configures the event sequence for rollback deploy operations.

type MockBlueprintResolver

type MockBlueprintResolver struct{}

func (*MockBlueprintResolver) Resolve

type MockBlueprintValidationStore

type MockBlueprintValidationStore struct {
	BlueprintValidations map[string]*manage.BlueprintValidation
	// contains filtered or unexported fields
}

func (*MockBlueprintValidationStore) Cleanup

func (s *MockBlueprintValidationStore) Cleanup(ctx context.Context, thresholdDate time.Time) (int64, error)

func (*MockBlueprintValidationStore) Get

func (*MockBlueprintValidationStore) Save

func (s *MockBlueprintValidationStore) Save(
	ctx context.Context,
	blueprintValidation *manage.BlueprintValidation,
) error

type MockChangesetStore

type MockChangesetStore struct {
	Changesets map[string]*manage.Changeset
	// contains filtered or unexported fields
}

func (*MockChangesetStore) Cleanup

func (s *MockChangesetStore) Cleanup(ctx context.Context, thresholdDate time.Time) (int64, error)

func (*MockChangesetStore) Get

func (*MockChangesetStore) Save

func (s *MockChangesetStore) Save(
	ctx context.Context,
	Changeset *manage.Changeset,
) error

type MockCleanupOperationsStore added in v0.3.0

type MockCleanupOperationsStore struct {
	Operations map[string]*manage.CleanupOperation
	SaveError  error
	// contains filtered or unexported fields
}

MockCleanupOperationsStore is a mock implementation of manage.CleanupOperations for testing purposes.

func (*MockCleanupOperationsStore) Get added in v0.3.0

func (*MockCleanupOperationsStore) GetLatestByType added in v0.3.0

func (s *MockCleanupOperationsStore) GetLatestByType(
	ctx context.Context,
	cleanupType manage.CleanupType,
) (*manage.CleanupOperation, error)

func (*MockCleanupOperationsStore) Save added in v0.3.0

func (*MockCleanupOperationsStore) Update added in v0.3.0

type MockClock

type MockClock struct {
	StaticTime   time.Time
	TimeSequence []time.Time
}

func (*MockClock) Now

func (c *MockClock) Now() time.Time

type MockEventStore

type MockEventStore struct {
	Events          map[string]*manage.Event
	EventPartitions map[string][]*manage.Event
	// contains filtered or unexported fields
}

func (*MockEventStore) Cleanup

func (s *MockEventStore) Cleanup(ctx context.Context, thresholdDate time.Time) (int64, error)

func (*MockEventStore) Get

func (s *MockEventStore) Get(
	ctx context.Context,
	id string,
) (manage.Event, error)

func (*MockEventStore) GetLastEventID added in v0.2.0

func (s *MockEventStore) GetLastEventID(
	ctx context.Context,
	channelType, channelID string,
) (string, error)

func (*MockEventStore) Save

func (s *MockEventStore) Save(
	ctx context.Context,
	evt *manage.Event,
) error

func (*MockEventStore) Stream

func (s *MockEventStore) Stream(
	ctx context.Context,
	params *manage.EventStreamParams,
	streamTo chan manage.Event,
	errChan chan error,
) (chan struct{}, error)

type MockPluginConfigPreparer

type MockPluginConfigPreparer struct {
	// Mapping of a config value to a list of diagnostics
	// that should be returned when the given value is used.
	Fixtures map[string][]*core.Diagnostic
}

func NewMockPluginConfigPreparer

func NewMockPluginConfigPreparer(
	fixtures map[string][]*core.Diagnostic,
) *MockPluginConfigPreparer

func (*MockPluginConfigPreparer) Prepare

type MockReconciliationResultsStore added in v0.2.0

type MockReconciliationResultsStore struct {
	Results map[string]*manage.ReconciliationResult
	// contains filtered or unexported fields
}

MockReconciliationResultsStore is a mock implementation of manage.ReconciliationResults for testing purposes.

func (*MockReconciliationResultsStore) Cleanup added in v0.2.0

func (s *MockReconciliationResultsStore) Cleanup(
	ctx context.Context,
	thresholdDate time.Time,
) (int64, error)

func (*MockReconciliationResultsStore) Get added in v0.2.0

func (*MockReconciliationResultsStore) GetAllByChangesetID added in v0.2.0

func (s *MockReconciliationResultsStore) GetAllByChangesetID(
	ctx context.Context,
	changesetID string,
) ([]*manage.ReconciliationResult, error)

func (*MockReconciliationResultsStore) GetAllByInstanceID added in v0.2.0

func (s *MockReconciliationResultsStore) GetAllByInstanceID(
	ctx context.Context,
	instanceID string,
) ([]*manage.ReconciliationResult, error)

func (*MockReconciliationResultsStore) GetLatestByChangesetID added in v0.2.0

func (s *MockReconciliationResultsStore) GetLatestByChangesetID(
	ctx context.Context,
	changesetID string,
) (*manage.ReconciliationResult, error)

func (*MockReconciliationResultsStore) GetLatestByInstanceID added in v0.2.0

func (s *MockReconciliationResultsStore) GetLatestByInstanceID(
	ctx context.Context,
	instanceID string,
) (*manage.ReconciliationResult, error)

func (*MockReconciliationResultsStore) Save added in v0.2.0

type ReconciliationTracker added in v0.2.0

type ReconciliationTracker struct {

	// CheckCalls contains all the check reconciliation inputs that were passed to CheckReconciliation.
	CheckCalls []*container.CheckReconciliationInput
	// ApplyCalls contains all the apply reconciliation inputs that were passed to ApplyReconciliation.
	ApplyCalls []*container.ApplyReconciliationInput
	// contains filtered or unexported fields
}

ReconciliationTracker tracks calls to CheckReconciliation and ApplyReconciliation for testing.

func NewReconciliationTracker added in v0.2.0

func NewReconciliationTracker() *ReconciliationTracker

NewReconciliationTracker creates a new ReconciliationTracker.

func (*ReconciliationTracker) GetApplyCalls added in v0.2.0

GetApplyCalls returns a copy of all apply reconciliation calls.

func (*ReconciliationTracker) GetCheckCalls added in v0.2.0

GetCheckCalls returns a copy of all check reconciliation calls.

func (*ReconciliationTracker) RecordApplyCall added in v0.2.0

func (t *ReconciliationTracker) RecordApplyCall(input *container.ApplyReconciliationInput)

RecordApplyCall records an apply reconciliation call.

func (*ReconciliationTracker) RecordCheckCall added in v0.2.0

func (t *ReconciliationTracker) RecordCheckCall(input *container.CheckReconciliationInput)

RecordCheckCall records a check reconciliation call.

func (*ReconciliationTracker) WasApplyCalled added in v0.2.0

func (t *ReconciliationTracker) WasApplyCalled() bool

WasApplyCalled returns true if ApplyReconciliation was called at least once.

func (*ReconciliationTracker) WasCheckCalled added in v0.2.0

func (t *ReconciliationTracker) WasCheckCalled() bool

WasCheckCalled returns true if CheckReconciliation was called at least once.

Jump to

Keyboard shortcuts

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