testing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package testing provides test utilities for CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureOutput

func CaptureOutput(f func()) (stdout string, stderr string)

CaptureOutput captures stdout and stderr while executing the given function.

func CreateTempDir

func CreateTempDir(t *testing.T) string

CreateTempDir creates a temporary directory for tests.

func CreateTempFile

func CreateTempFile(t *testing.T, content string) string

CreateTempFile creates a temporary file with the given content and returns its path. The caller is responsible for removing the file.

func CreateTempFileWithExt

func CreateTempFileWithExt(t *testing.T, ext, content string) string

CreateTempFileWithExt creates a temporary file with given extension and content.

func ExecuteCommand

func ExecuteCommand(root *cobra.Command, args ...string) (string, error)

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

func ResetCommand(cmd *cobra.Command)

ResetCommand resets a cobra command for reuse in tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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