testutils

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstanceCreatesFromEngine added in v0.10.0

func InstanceCreatesFromEngine(eng engine.DeployEngine) int

InstanceCreatesFromEngine returns how many times CreateBlueprintInstance was called on the test engine. Returns 0 if the engine is not a test engine.

func InstanceUpdatesFromEngine added in v0.10.0

func InstanceUpdatesFromEngine(eng engine.DeployEngine) []string

InstanceUpdatesFromEngine returns the instance IDs UpdateBlueprintInstance was called with on the test engine, in order. Returns nil if the engine is not a test engine.

func Key added in v0.1.3

func Key(model *teatest.TestModel, key string)

Key is a generic helper function to send any single key message to the model.

func KeyBackspace added in v0.1.2

func KeyBackspace(model *teatest.TestModel)

KeyBackspace is a helper function to send a backspace key message to the model.

func KeyDown

func KeyDown(model *teatest.TestModel)

KeyDown is a helper function to send a key down message to the model.

func KeyEnd added in v0.1.2

func KeyEnd(model *teatest.TestModel)

KeyEnd is a helper function to send an end key message to the model.

func KeyEnter

func KeyEnter(model *teatest.TestModel)

KeyEnter is a helper function to send a key enter message to the model.

func KeyEscape added in v0.1.2

func KeyEscape(model *teatest.TestModel)

KeyEscape is a helper function to send an escape key message to the model.

func KeyHome added in v0.1.2

func KeyHome(model *teatest.TestModel)

KeyHome is a helper function to send a home key message to the model.

func KeyJ added in v0.1.2

func KeyJ(model *teatest.TestModel)

KeyJ is a helper function to send a 'j' key message to the model (vim down).

func KeyK added in v0.1.2

func KeyK(model *teatest.TestModel)

KeyK is a helper function to send a 'k' key message to the model (vim up).

func KeyLeft

func KeyLeft(model *teatest.TestModel)

KeyLeft is a helper function to send a key left message to the model.

func KeyPageDown added in v0.1.2

func KeyPageDown(model *teatest.TestModel)

KeyPageDown is a helper function to send a page down key message to the model.

func KeyPageUp added in v0.1.2

func KeyPageUp(model *teatest.TestModel)

KeyPageUp is a helper function to send a page up key message to the model.

func KeyQ

func KeyQ(model *teatest.TestModel)

KeyQ is a helper function to send a key q message to the model.

func KeyRight

func KeyRight(model *teatest.TestModel)

KeyRight is a helper function to send a key right message to the model.

func KeyS added in v0.1.3

func KeyS(model *teatest.TestModel)

KeyS is a helper function to send a 's' key message to the model.

func KeyTab added in v0.1.2

func KeyTab(model *teatest.TestModel)

KeyTab is a helper function to send a tab key message to the model.

func KeyUp

func KeyUp(model *teatest.TestModel)

KeyUp is a helper function to send a key up message to the model.

func LastApplyReconciliationPayloadFromEngine added in v0.10.0

func LastApplyReconciliationPayloadFromEngine(eng engine.DeployEngine) *types.ApplyReconciliationPayload

LastApplyReconciliationPayloadFromEngine returns the last ApplyReconciliation payload received by the test engine. Returns nil if the engine is not a test engine, or if no reconciliation has been applied.

func LastChangesetPayloadFromEngine added in v0.10.0

func LastChangesetPayloadFromEngine(eng engine.DeployEngine) *types.CreateChangesetPayload

LastChangesetPayloadFromEngine returns the last CreateChangeset payload received by the test engine. Returns nil if the engine is not a test engine, or if no changes were staged.

func LastValidationPayloadFromEngine added in v0.4.0

func LastValidationPayloadFromEngine(eng engine.DeployEngine) *types.CreateBlueprintValidationPayload

LastValidationPayloadFromEngine returns the last CreateBlueprintValidation payload received by the test engine, if any. Returns nil if the engine is not a test engine, or if no validation has been created.

func NewSaveBuffer

func NewSaveBuffer() *safeBuffer

NewSaveBuffer creates a new buffer that can be used to capture output from TUI apps in headless mode in a thread-safe manner.

func NewTestDeployEngine

func NewTestDeployEngine(stubValidationEvents []*types.BlueprintValidationEvent) engine.DeployEngine

func NewTestDeployEngineForInspect added in v0.1.3

func NewTestDeployEngineForInspect(
	instanceState *state.InstanceState,
	deploymentEvents []*types.BlueprintInstanceEvent,
) engine.DeployEngine

NewTestDeployEngineForInspect creates a test deploy engine for inspect scenarios. If deploymentEvents is nil, no streaming will occur (static view mode). If deploymentEvents is non-nil, events will be streamed (in-progress mode).

func NewTestDeployEngineForInspectNotFound added in v0.1.3

func NewTestDeployEngineForInspectNotFound() engine.DeployEngine

NewTestDeployEngineForInspectNotFound creates a test deploy engine for inspect scenarios where the instance is not found.

func NewTestDeployEngineForList added in v0.1.3

func NewTestDeployEngineForList(instances []state.InstanceSummary) engine.DeployEngine

NewTestDeployEngineForList creates a test deploy engine for list scenarios.

func NewTestDeployEngineForListError added in v0.1.3

func NewTestDeployEngineForListError() engine.DeployEngine

NewTestDeployEngineForListError creates a test deploy engine that returns an error on list.

func NewTestDeployEngineWithChangesetFetchError added in v0.9.0

func NewTestDeployEngineWithChangesetFetchError(err error) engine.DeployEngine

NewTestDeployEngineWithChangesetFetchError creates a test deploy engine that returns an error on GetChangeset, simulating a change set that cannot be read back.

func NewTestDeployEngineWithDeployment added in v0.1.3

func NewTestDeployEngineWithDeployment(
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceID string,
	instanceState *state.InstanceState,
) engine.DeployEngine

NewTestDeployEngineWithDeployment creates a test deploy engine with deployment event support.

func NewTestDeployEngineWithDeploymentAndChangeset added in v0.1.3

func NewTestDeployEngineWithDeploymentAndChangeset(
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceID string,
	instanceState *state.InstanceState,
	changesetChanges *changes.BlueprintChanges,
) engine.DeployEngine

NewTestDeployEngineWithDeploymentAndChangeset creates a test deploy engine with deployment event support and changeset changes that can be fetched via GetChangeset.

func NewTestDeployEngineWithDeploymentError added in v0.1.3

func NewTestDeployEngineWithDeploymentError(err error) engine.DeployEngine

NewTestDeployEngineWithDeploymentError creates a test deploy engine that returns an error on CreateBlueprintInstance or UpdateBlueprintInstance.

func NewTestDeployEngineWithDestroyError added in v0.1.3

func NewTestDeployEngineWithDestroyError(err error) engine.DeployEngine

NewTestDeployEngineWithDestroyError creates a test deploy engine that returns an error on DestroyBlueprintInstance calls.

func NewTestDeployEngineWithInstanceCreatedAfterLookup added in v0.10.0

func NewTestDeployEngineWithInstanceCreatedAfterLookup(
	stubStagingEvents []*types.ChangeStagingEvent,
	changesetID string,
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceState *state.InstanceState,
	instanceName string,
) engine.DeployEngine

NewTestDeployEngineWithInstanceCreatedAfterLookup creates a test deploy engine for staging and deploying a name that another deploy takes in between: the first lookup of instanceName reports it as not found, and later lookups find instanceState.

func NewTestDeployEngineWithInstanceLookupError added in v0.10.0

func NewTestDeployEngineWithInstanceLookupError(err error) engine.DeployEngine

NewTestDeployEngineWithInstanceLookupError creates a test deploy engine whose GetBlueprintInstance fails with err, for an engine that cannot be reached.

func NewTestDeployEngineWithMissingChangeset added in v0.9.0

func NewTestDeployEngineWithMissingChangeset(
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceID string,
	instanceState *state.InstanceState,
) engine.DeployEngine

NewTestDeployEngineWithMissingChangeset creates a test deploy engine for which GetChangeset finds nothing, simulating a change set ID that does not exist.

func NewTestDeployEngineWithNoInstanceState added in v0.1.3

func NewTestDeployEngineWithNoInstanceState(
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceID string,
) engine.DeployEngine

NewTestDeployEngineWithNoInstanceState creates a test deploy engine that returns an error when GetBlueprintInstance is called (simulating no instance state available).

func NewTestDeployEngineWithStaging added in v0.1.2

func NewTestDeployEngineWithStaging(
	stubStagingEvents []*types.ChangeStagingEvent,
	changesetID string,
) engine.DeployEngine

NewTestDeployEngineWithStaging creates a test deploy engine with staging event support.

func NewTestDeployEngineWithStagingAndDeployment added in v0.10.0

func NewTestDeployEngineWithStagingAndDeployment(
	stubStagingEvents []*types.ChangeStagingEvent,
	changesetID string,
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceState *state.InstanceState,
) engine.DeployEngine

NewTestDeployEngineWithStagingAndDeployment creates a test deploy engine for staging changes and then deploying them: staging streams stubStagingEvents for changesetID, and the deployment streams stubDeploymentEvents for instanceState, which GetBlueprintInstance also returns for any ID or name.

func NewTestDeployEngineWithStagingError added in v0.1.2

func NewTestDeployEngineWithStagingError(err error) engine.DeployEngine

NewTestDeployEngineWithStagingError creates a test deploy engine that returns an error on CreateChangeset.

func NewTestDeployEngineWithStreamError added in v0.9.0

func NewTestDeployEngineWithStreamError(
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceID string,
	instanceState *state.InstanceState,
	streamErr error,
	streamErrDelay time.Duration,
) engine.DeployEngine

NewTestDeployEngineWithStreamError creates a test deploy engine that streams the given deployment events and then, after streamErrDelay, reports an error on the error channel the way the client does when a deployment fails mid-run. The delay gives the streamed events time to be processed first, and a delay longer than the model's error poll window exercises an error that arrives after a poll has expired.

func NewTestDeployEngineWithUnknownInstanceName added in v0.10.0

func NewTestDeployEngineWithUnknownInstanceName(
	stubDeploymentEvents []*types.BlueprintInstanceEvent,
	instanceID string,
	instanceState *state.InstanceState,
	unknownInstanceName string,
) engine.DeployEngine

NewTestDeployEngineWithUnknownInstanceName creates a test deploy engine for deploying a new instance by name: GetBlueprintInstance returns a 404 client error for unknownInstanceName, and the deployment creates instanceState.

func WaitFor

func WaitFor(t *testing.T, output io.Reader, condition func(output []byte) bool)

WaitFor is a helper function to wait for a condition to be true with a pre-defined check interval (20ms) and timeout duration (10 seconds).

func WaitForContains

func WaitForContains(t *testing.T, output io.Reader, text string)

WaitForContains is a helper function to wait for a string to be present in the output.

func WaitForContainsAll

func WaitForContainsAll(t *testing.T, output io.Reader, texts ...string)

WaitForContainsAll is a helper function to wait for all strings to be present in the output.

Types

This section is empty.

Jump to

Keyboard shortcuts

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