mock

package module
v0.0.0-...-64632cf Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mock provides a testify-based implementation of invoke.Environment. It is intended for tests and test-support packages, not production runtime use.

Usage:

m := mock.New()
m.On("Run", ctx, mock.AnythingOfType("*invoke.Command")).
    Return(&invoke.Result{ExitCode: 0}, nil)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteOutput

func WriteOutput(w io.Writer, content string) func(mock.Arguments)

WriteOutput is a helper to simulate output writing for mocked processes. Usage: mockProcess.On("Wait").Run(WriteOutput(cmd.Stdout, "output")).Return(nil).

Types

type Environment

type Environment struct {
	mock.Mock
}

Environment implements a mock invoke.Environment using testify/mock.

func New

func New() *Environment

New creates a new mock environment.

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) LookPath

func (m *Environment) LookPath(_ context.Context, file string) (string, error)

LookPath mocks looking up an executable path.

func (*Environment) Run

func (m *Environment) Run(ctx context.Context, cmd *invoke.Command) (*invoke.Result, error)

Run mocks running a command to completion.

func (*Environment) Start

func (m *Environment) Start(ctx context.Context, cmd *invoke.Command) (invoke.Process, error)

Start mocks starting a command asynchronously.

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.

type Process

type Process struct {
	mock.Mock
}

Process implements a mock invoke.Process using testify/mock.

func (*Process) Close

func (m *Process) Close() error

Close mocks closing the process.

func (*Process) Signal

func (m *Process) Signal(sig os.Signal) error

Signal mocks sending a signal to the process.

func (*Process) Wait

func (m *Process) Wait() (*invoke.Result, error)

Wait mocks waiting for the process to complete.

Jump to

Keyboard shortcuts

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