Documentation
¶
Index ¶
- func WithShellExecutor(ctx context.Context, executor ShellExecutor) context.Context
- type DefaultShellExecutor
- type MockCall
- type MockShellExecutor
- func (m *MockShellExecutor) AddCommandString(command string, args []string, output string, err error)
- func (m *MockShellExecutor) AddPartialMatcherString(command string, args []string, output string, err error)
- func (m *MockShellExecutor) Exec(ctx context.Context, command string, args ...string) ([]byte, error)
- func (m *MockShellExecutor) GetCallLog() []MockCall
- type ShellExecutor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithShellExecutor ¶
func WithShellExecutor(ctx context.Context, executor ShellExecutor) context.Context
WithShellExecutor returns a context with the given shell executor
Types ¶
type DefaultShellExecutor ¶
type DefaultShellExecutor struct{}
DefaultShellExecutor implements ShellExecutor using os/exec
type MockShellExecutor ¶
type MockShellExecutor struct {
// contains filtered or unexported fields
}
MockShellExecutor is a mock implementation of ShellExecutor for testing
func NewMockShellExecutor ¶
func NewMockShellExecutor() *MockShellExecutor
NewMockShellExecutor creates a new mock shell executor
func (*MockShellExecutor) AddCommandString ¶
func (m *MockShellExecutor) AddCommandString(command string, args []string, output string, err error)
AddCommandString mocks a command with specific arguments and a string output
func (*MockShellExecutor) AddPartialMatcherString ¶
func (m *MockShellExecutor) AddPartialMatcherString(command string, args []string, output string, err error)
AddPartialMatcherString mocks a command with partial argument matching
func (*MockShellExecutor) Exec ¶
func (m *MockShellExecutor) Exec(ctx context.Context, command string, args ...string) ([]byte, error)
Exec records the call and returns a mocked output or error
func (*MockShellExecutor) GetCallLog ¶
func (m *MockShellExecutor) GetCallLog() []MockCall
GetCallLog returns the history of commands executed
type ShellExecutor ¶
type ShellExecutor interface {
Exec(ctx context.Context, command string, args ...string) (output []byte, err error)
}
ShellExecutor defines the interface for executing shell commands
func GetShellExecutor ¶
func GetShellExecutor(ctx context.Context) ShellExecutor
GetShellExecutor retrieves the shell executor from context, or returns default