Documentation
¶
Overview ¶
Package testing provides test utilities for CLI commands.
Index ¶
- func CaptureOutput(f func()) (stdout string, stderr string)
- func CreateTempDir(t *testing.T) string
- func CreateTempFile(t *testing.T, content string) string
- func CreateTempFileWithExt(t *testing.T, ext, content string) string
- func ExecuteCommand(root *cobra.Command, args ...string) (string, error)
- func ExecuteCommandWithErr(root *cobra.Command, args ...string) (stdout string, stderr string, err error)
- func ResetCommand(cmd *cobra.Command)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureOutput ¶
CaptureOutput captures stdout and stderr while executing the given function.
func CreateTempDir ¶
CreateTempDir creates a temporary directory for tests.
func CreateTempFile ¶
CreateTempFile creates a temporary file with the given content and returns its path. The caller is responsible for removing the file.
func CreateTempFileWithExt ¶
CreateTempFileWithExt creates a temporary file with given extension and content.
func ExecuteCommand ¶
ExecuteCommand runs a cobra command with the given arguments and returns the output.
func ExecuteCommandWithErr ¶
func ExecuteCommandWithErr(root *cobra.Command, args ...string) (stdout string, stderr string, err error)
ExecuteCommandWithErr runs a cobra command and captures stdout and stderr separately.
func ResetCommand ¶
ResetCommand resets a cobra command for reuse in tests.
Types ¶
This section is empty.