Documentation
¶
Overview ¶
Package spin provides utilities for orchestrating Spin CLI commands
Index ¶
- func Build(ctx context.Context, options ...string) error
- func Deploy(ctx context.Context, options ...string) error
- func EnsureInstalled() error
- func New(ctx context.Context, template, name string, options ...string) error
- func Registry(ctx context.Context, subcommand string, options ...string) error
- func Up(ctx context.Context, options ...string) error
- func WaitForReady(ctx context.Context, address string, timeout time.Duration) error
- func Watch(ctx context.Context, options ...string) error
- type Executor
- type MockCall
- type MockExecutor
- func (m *MockExecutor) AssertCalled(method string, args ...string) error
- func (m *MockExecutor) CallCount(method string) int
- func (m *MockExecutor) IsInstalled() bool
- func (m *MockExecutor) LastCall(method string) *MockCall
- func (m *MockExecutor) Reset()
- func (m *MockExecutor) Run(ctx context.Context, args ...string) error
- func (m *MockExecutor) RunInteractive(ctx context.Context, args ...string) error
- func (m *MockExecutor) RunWithInput(ctx context.Context, input io.Reader, args ...string) error
- func (m *MockExecutor) RunWithOutput(ctx context.Context, args ...string) (string, error)
- func (m *MockExecutor) SetRunError(err error)
- func (m *MockExecutor) SetRunWithOutputResponse(output string, err error)
- func (m *MockExecutor) SetVersionOutput(version string)
- func (m *MockExecutor) SimulateCommandOutput(command string)
- func (m *MockExecutor) Version() (string, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitForReady ¶
WaitForReady waits for Spin to be ready on a given address
Types ¶
type Executor ¶
type Executor interface {
Run(ctx context.Context, args ...string) error
RunWithOutput(ctx context.Context, args ...string) (string, error)
RunWithInput(ctx context.Context, input string, args ...string) error
RunInteractive(ctx context.Context, args ...string) error
IsInstalled() bool
Version() (string, error)
}
Executor provides an interface for executing Spin commands
func NewExecutor ¶
NewExecutor creates a new Spin executor
type MockExecutor ¶
type MockExecutor struct {
// Configuration for mock behavior
RunFunc func(ctx context.Context, args ...string) error
RunWithOutputFunc func(ctx context.Context, args ...string) (string, error)
RunWithInputFunc func(ctx context.Context, input io.Reader, args ...string) error
RunInteractiveFunc func(ctx context.Context, args ...string) error
IsInstalledFunc func() bool
VersionFunc func() (string, error)
// Track calls for assertions
Calls []MockCall
}
MockExecutor is a mock implementation of the Executor interface for testing
func NewMockExecutor ¶
func NewMockExecutor() *MockExecutor
NewMockExecutor creates a new mock executor with sensible defaults
func (*MockExecutor) AssertCalled ¶
func (m *MockExecutor) AssertCalled(method string, args ...string) error
AssertCalled verifies a method was called with specific arguments
func (*MockExecutor) CallCount ¶
func (m *MockExecutor) CallCount(method string) int
CallCount returns the number of times a method was called
func (*MockExecutor) IsInstalled ¶
func (m *MockExecutor) IsInstalled() bool
IsInstalled implements Executor
func (*MockExecutor) LastCall ¶
func (m *MockExecutor) LastCall(method string) *MockCall
LastCall returns the most recent call for a given method
func (*MockExecutor) Run ¶
func (m *MockExecutor) Run(ctx context.Context, args ...string) error
Run implements Executor
func (*MockExecutor) RunInteractive ¶
func (m *MockExecutor) RunInteractive(ctx context.Context, args ...string) error
RunInteractive implements Executor
func (*MockExecutor) RunWithInput ¶
RunWithInput implements Executor
func (*MockExecutor) RunWithOutput ¶
RunWithOutput implements Executor
func (*MockExecutor) SetRunError ¶
func (m *MockExecutor) SetRunError(err error)
SetRunError makes Run return an error
func (*MockExecutor) SetRunWithOutputResponse ¶
func (m *MockExecutor) SetRunWithOutputResponse(output string, err error)
SetRunWithOutputResponse sets the response for RunWithOutput
func (*MockExecutor) SetVersionOutput ¶
func (m *MockExecutor) SetVersionOutput(version string)
SetVersionOutput sets the mock version output
func (*MockExecutor) SimulateCommandOutput ¶
func (m *MockExecutor) SimulateCommandOutput(command string)
SimulateCommandOutput simulates output based on the command
func (*MockExecutor) Version ¶
func (m *MockExecutor) Version() (string, error)
Version implements Executor
type Option ¶
type Option func(*executor)
Option configures an executor
func WithOutput ¶
WithOutput sets custom output writers