testutils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const TestUpstreamCommit = "test-upstream-commit-aabb1122"

TestUpstreamCommit is the default commit hash used by TestEnv.WriteDefaultLock and TestEnv.AddUpstreamComponent.

Variables

This section is empty.

Functions

func PrepareCommand

func PrepareCommand(cmd *cobra.Command, env *azldev.Env) *cobra.Command

Types

type TestEnv

type TestEnv struct {
	Env    *azldev.Env
	Config *projectconfig.ProjectConfig

	TestInterfaces azldev.SystemInterfaces

	// Test implementations
	CmdFactory       *testctx.TestCmdFactory
	DryRunnable      opctx.DryRunnable
	EventListener    opctx.EventListener
	TestFS           opctx.FS
	TestOSEnv        opctx.OSEnv
	CommandsExecuted [][]string
}

Test environment, useful for unit-testing azldev CLI commands. Contains an azldev.Env constructed with injected dependencies that redirect filesystem and OS environmental access to included test objects.

func NewTestEnv

func NewTestEnv(t *testing.T) *TestEnv

Constructs a new TestEnv.

func (*TestEnv) AddUpstreamComponent added in v0.2.0

func (e *TestEnv) AddUpstreamComponent(t *testing.T, name string)

AddUpstreamComponent registers an upstream component in the test config and writes a minimal lock file so lock validation passes. Use this instead of setting env.Config.Components directly when the test doesn't need to customize the lock data.

func (*TestEnv) FS

func (e *TestEnv) FS() opctx.FS

FS implements the opctx.FileSystemFactory interface.

func (*TestEnv) OSEnv

func (e *TestEnv) OSEnv() opctx.OSEnv

FS implements the opctx.OSEnvFactory interface.

func (*TestEnv) WriteDefaultLock added in v0.2.0

func (e *TestEnv) WriteDefaultLock(t *testing.T, name string)

WriteDefaultLock writes a minimal valid lock file for the named component. Use this when a test adds a component inline (with custom config) and just needs lock validation to pass.

func (*TestEnv) WriteLock added in v0.2.0

func (e *TestEnv) WriteLock(t *testing.T, name string, lock *lockfile.ComponentLock)

WriteLock creates a lock file on the test filesystem for the given component. Uses the same lock directory layout as the production lockfile.Store.

Jump to

Keyboard shortcuts

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