Documentation
¶
Index ¶
- func FindRepoRoot() (string, error)
- func NewMockCommand(name string, flags map[string]string) *cobra.Command
- func NewMockCommandWithBool(name string, boolFlags map[string]bool) *cobra.Command
- func NewMockCommandWithMixed(name string, stringFlags map[string]string, boolFlags map[string]bool) *cobra.Command
- type AtmosRunner
- type MockFSBuilder
- func (b *MockFSBuilder) Build() *filesystem.MockFileSystem
- func (b *MockFSBuilder) WithFile(path string, content []byte) *MockFSBuilder
- func (b *MockFSBuilder) WithFileError(path string, err error) *MockFSBuilder
- func (b *MockFSBuilder) WithMkdirAll(path string, perm os.FileMode) *MockFSBuilder
- func (b *MockFSBuilder) WithMkdirAllError(path string, perm os.FileMode, err error) *MockFSBuilder
- func (b *MockFSBuilder) WithRemoveAll(path string, err error) *MockFSBuilder
- func (b *MockFSBuilder) WithStat(path string, info os.FileInfo, err error) *MockFSBuilder
- func (b *MockFSBuilder) WithTempDir(path string) *MockFSBuilder
- func (b *MockFSBuilder) WithTempDirError(err error) *MockFSBuilder
- func (b *MockFSBuilder) WithWriteFile(path string, content []byte, perm os.FileMode) *MockFSBuilder
- func (b *MockFSBuilder) WithWriteFileError(path string, content []byte, perm os.FileMode, err error) *MockFSBuilder
- type SandboxEnvironment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindRepoRoot ¶ added in v1.196.0
FindRepoRoot finds the root of the git repository.
func NewMockCommand ¶ added in v1.195.0
NewMockCommand creates a mock Cobra command with the specified flags for testing. This helper simplifies test setup by providing a fluent interface for creating commands.
Example:
cmd := NewMockCommand("test", map[string]string{
"stack": "dev",
"format": "yaml",
})
func NewMockCommandWithBool ¶ added in v1.195.0
NewMockCommandWithBool creates a mock Cobra command with boolean flags.
Types ¶
type AtmosRunner ¶
type AtmosRunner struct {
// contains filtered or unexported fields
}
AtmosRunner manages running Atmos with optional coverage collection.
func NewAtmosRunner ¶
func NewAtmosRunner(coverDir string) *AtmosRunner
NewAtmosRunner creates a runner that always builds Atmos, with or without coverage instrumentation.
func (*AtmosRunner) BinaryPath ¶
func (r *AtmosRunner) BinaryPath() string
BinaryPath returns the path to the binary being used.
func (*AtmosRunner) Build ¶
func (r *AtmosRunner) Build() error
Build always builds Atmos, with or without coverage instrumentation.
func (*AtmosRunner) Cleanup ¶
func (r *AtmosRunner) Cleanup()
Cleanup removes temporary binary and its directory.
func (*AtmosRunner) Command ¶
func (r *AtmosRunner) Command(args ...string) *exec.Cmd
Command creates an exec.Cmd with GOCOVERDIR and PATH set for nested atmos calls.
func (*AtmosRunner) CommandContext ¶
CommandContext creates an exec.Cmd with context, GOCOVERDIR and PATH set for nested atmos calls.
type MockFSBuilder ¶ added in v1.195.0
type MockFSBuilder struct {
// contains filtered or unexported fields
}
MockFSBuilder provides a fluent interface for building mock filesystem expectations. This simplifies test setup by allowing method chaining for common filesystem operations.
Example:
mockFS := NewMockFS(ctrl).
WithTempDir("/tmp/test-12345").
WithFile("/tmp/test-12345/config.yaml", []byte("test: data")).
WithRemoveAll("/tmp/test-12345", nil).
Build()
func NewMockFS ¶ added in v1.195.0
func NewMockFS(ctrl *gomock.Controller) *MockFSBuilder
NewMockFS creates a new MockFSBuilder.
func (*MockFSBuilder) Build ¶ added in v1.195.0
func (b *MockFSBuilder) Build() *filesystem.MockFileSystem
Build returns the configured MockFileSystem.
func (*MockFSBuilder) WithFile ¶ added in v1.195.0
func (b *MockFSBuilder) WithFile(path string, content []byte) *MockFSBuilder
WithFile sets up an expectation for ReadFile to return the specified content.
func (*MockFSBuilder) WithFileError ¶ added in v1.195.0
func (b *MockFSBuilder) WithFileError(path string, err error) *MockFSBuilder
WithFileError sets up an expectation for ReadFile to return an error.
func (*MockFSBuilder) WithMkdirAll ¶ added in v1.195.0
func (b *MockFSBuilder) WithMkdirAll(path string, perm os.FileMode) *MockFSBuilder
WithMkdirAll sets up an expectation for MkdirAll to succeed.
func (*MockFSBuilder) WithMkdirAllError ¶ added in v1.195.0
func (b *MockFSBuilder) WithMkdirAllError(path string, perm os.FileMode, err error) *MockFSBuilder
WithMkdirAllError sets up an expectation for MkdirAll to return an error.
func (*MockFSBuilder) WithRemoveAll ¶ added in v1.195.0
func (b *MockFSBuilder) WithRemoveAll(path string, err error) *MockFSBuilder
WithRemoveAll sets up an expectation for RemoveAll to succeed or fail.
func (*MockFSBuilder) WithStat ¶ added in v1.195.0
func (b *MockFSBuilder) WithStat(path string, info os.FileInfo, err error) *MockFSBuilder
WithStat sets up an expectation for Stat to return the specified FileInfo.
func (*MockFSBuilder) WithTempDir ¶ added in v1.195.0
func (b *MockFSBuilder) WithTempDir(path string) *MockFSBuilder
WithTempDir sets up an expectation for MkdirTemp to return the specified path.
func (*MockFSBuilder) WithTempDirError ¶ added in v1.195.0
func (b *MockFSBuilder) WithTempDirError(err error) *MockFSBuilder
WithTempDirError sets up an expectation for MkdirTemp to return an error.
func (*MockFSBuilder) WithWriteFile ¶ added in v1.195.0
func (b *MockFSBuilder) WithWriteFile(path string, content []byte, perm os.FileMode) *MockFSBuilder
WithWriteFile sets up an expectation for WriteFile to succeed.
func (*MockFSBuilder) WithWriteFileError ¶ added in v1.195.0
func (b *MockFSBuilder) WithWriteFileError(path string, content []byte, perm os.FileMode, err error) *MockFSBuilder
WithWriteFileError sets up an expectation for WriteFile to return an error.
type SandboxEnvironment ¶
SandboxEnvironment holds the state for a sandboxed test.
func SetupSandbox ¶
func SetupSandbox(t *testing.T, workdir string) (*SandboxEnvironment, error)
SetupSandbox creates an isolated test environment with copied components.
func (*SandboxEnvironment) Cleanup ¶
func (s *SandboxEnvironment) Cleanup()
Cleanup removes the sandbox directory.
func (*SandboxEnvironment) GetEnvironmentVariables ¶
func (s *SandboxEnvironment) GetEnvironmentVariables() map[string]string
GetEnvironmentVariables returns environment variables for sandbox execution.