exec

package
v0.0.0-...-b2e0f1d Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package exec provides wrapped implementations of os/exec's Command and CommandContext functions that allow for command creation to be overridden, thereby allowing commands to be mocked.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(name string, arg ...string) *goexec.Cmd

Command wraps os/exec.Command, and implements the same behaviour.

func CommandContext

func CommandContext(ctx context.Context, name string, arg ...string) *goexec.Cmd

CommandContext wraps os/exec.CommandContext, and implements the same behaviour.

Types

type CmdCreator

type CmdCreator func(context.Context, string, ...string) *goexec.Cmd

CmdCreator instances are used to create commands. os/exec.CommandContext is a valid CmdCreator.

type CmdCreatorMiddleware

type CmdCreatorMiddleware struct {
	// contains filtered or unexported fields
}

CmdCreatorMiddleware creates *exec.Cmd instances that delegate command creation to a provided callback.

func NewMiddleware

func NewMiddleware(mock func(context.Context, CmdCreator, string, ...string) *goexec.Cmd) CmdCreatorMiddleware

NewMiddleware adds a middleware to the command creation stack.

func (CmdCreatorMiddleware) Remove

func (mc CmdCreatorMiddleware) Remove()

Remove removes the command creation middleware from the stack.

Directories

Path Synopsis
Package expect uses the middleware concept in internal/exec to mock external commands.
Package expect uses the middleware concept in internal/exec to mock external commands.

Jump to

Keyboard shortcuts

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