Documentation
¶
Overview ¶
Package mock provides a controllable implementation of invoke.Environment for testing purposes.
It allows defining expectations for command execution and file operations, enabling deterministic unit tests for code that builds upon the invoke library.
Usage:
m := mock.New()
m.OnCommand("git status").Return(0, "On branch main", "")
// pass 'm' to your logic
Index ¶
- func WriteOutput(w io.Writer, content string) func(mock.Arguments)
- type Environment
- func (m *Environment) Close() error
- func (m *Environment) Download(ctx context.Context, remotePath, localPath string, opts ...invoke.FileOption) error
- func (m *Environment) LookPath(_ context.Context, file string) (string, error)
- func (m *Environment) Run(ctx context.Context, cmd *invoke.Command) (*invoke.Result, error)
- func (m *Environment) Start(ctx context.Context, cmd *invoke.Command) (invoke.Process, error)
- func (m *Environment) TargetOS() invoke.TargetOS
- func (m *Environment) Upload(ctx context.Context, localPath, remotePath string, opts ...invoke.FileOption) error
- type Process
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Environment ¶
Environment implements a mock invoke.Environment using testify/mock.
func (*Environment) Close ¶
func (m *Environment) Close() error
Close mocks closing the environment.
func (*Environment) Download ¶
func (m *Environment) Download(ctx context.Context, remotePath, localPath string, opts ...invoke.FileOption) error
Download mocks downloading a file from the remote environment.
func (*Environment) TargetOS ¶
func (m *Environment) TargetOS() invoke.TargetOS
TargetOS mocks returning the target operating system.
func (*Environment) Upload ¶
func (m *Environment) Upload(ctx context.Context, localPath, remotePath string, opts ...invoke.FileOption) error
Upload mocks uploading a file to the remote environment.
Click to show internal directories.
Click to hide internal directories.