cmdtest

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestTmpDir    = ".tmp"
	TestOutputDir = "output"
)

Variables

This section is empty.

Functions

func CopyCommandChain

func CopyCommandChain(cmd *cobra.Command, args ...string) (cmdCpy, rootCpy *cobra.Command)

CopyCommandChain do following things: - Make copy of given command and its parents/ancestors. - Fix arguments of its ancestors. - Attach the given command chain to a copy of predefined test root command (to mimic how main() function works) This function returns copied command and a copy of its root command. Two values may be same if they are the root

func DryRunCobraCommand

func DryRunCobraCommand(ctx context.Context, wd string, cmd *cobra.Command, handler TestDryRunHandler, args ...string) error

DryRunCobraCommand Run given cobra.Command in given work dir relative to "testdata"

func DryRunShellWithFilter

func DryRunShellWithFilter(ignoreMatched bool, matchers ...matcher.StringMatcher) cmdutils.DryRunFunc

func PathRelativeToTestdata

func PathRelativeToTestdata(pathComponents ...string) string

func SetupDryRun

func SetupDryRun(handler TestDryRunHandler) test.SetupFunc

func SetupResetPackageVars

func SetupResetPackageVars() test.SetupFunc

func WithDryRun

func WithDryRun(handler TestDryRunHandler) test.Options

Types

type TestDryRunHandler

type TestDryRunHandler map[cmdutils.DryRunCmdType]cmdutils.DryRunFunc

func (TestDryRunHandler) Handle

func (h TestDryRunHandler) Handle(ctx context.Context, cmdType cmdutils.DryRunCmdType, args ...interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

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