Documentation ¶
Index ¶
- func CreateTee(t *testing.T, silent bool) *pkgTesting.Tee
- func HideEnv(t *testing.T) func(t *testing.T)
- func InitTestConfig(config string) error
- func PrepareStdinResponse(s string, t *testing.T) (*os.File, string)
- func PreventAtExit(t *testing.T) func(int) bool
- func PreventExitWithNonZeroExitCode(t *testing.T) func(int) bool
- func ResetStdin(origStdin *os.File, tmpFile string)
- func RunCommand(f func(*cobra.Command, []string))
- func SetOptionValue(t *testing.T, testOption TestOption)
- func SetupTmpMinishiftHome(t *testing.T) string
- func TearDown(testDir string, tee *pkgTesting.Tee)
- func UnsetValues(testOption TestOption)
- func VerifyExitCodeAndMessage(t *testing.T, tee *pkgTesting.Tee, expectedExitCode int, ...) func(int) bool
- type TestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTee ¶
func CreateTee(t *testing.T, silent bool) *pkgTesting.Tee
CreateTee splits the stdout and stderr in order to capture these streams into a buffer during test execution. If silent is true, the original output streams are silenced.
func HideEnv ¶
Temporarily unsets the env variables for the test cases returns a function to reset them to their initial values
func InitTestConfig ¶
func PrepareStdinResponse ¶
PrepareStdinResponse creates a temproary file with a prepared content which then is used as os.Stdin to test user input. The orignal os.Stdin file handle is returned as well as the path of the file containing the canned stdin responses.
func PreventAtExit ¶
PreventAtExit prevents an early/unexpected termination via atexit.
func PreventExitWithNonZeroExitCode ¶
PreventExitWithNonZeroReturn creates an exit handler function which will cast a veto when the program tries to call os.Exit with a non zero exit code. This is useful to prevent a test from exiting early due to failing validation check.
func ResetStdin ¶
ResetStdin resets os.Stdin to the specified original file handle. It also deletes a potenitally created tmp file containing dummy stdin data.
func RunCommand ¶
func SetOptionValue ¶
func SetOptionValue(t *testing.T, testOption TestOption)
func SetupTmpMinishiftHome ¶
SetupTmpMinishiftHome creates a tmp directory and points MINISHIFT_HOME to it. It returns the path to this tmp directory
func TearDown ¶
func TearDown(testDir string, tee *pkgTesting.Tee)
func UnsetValues ¶
func UnsetValues(testOption TestOption)
func VerifyExitCodeAndMessage ¶
func VerifyExitCodeAndMessage(t *testing.T, tee *pkgTesting.Tee, expectedExitCode int, expectedErrorMessage string) func(int) bool
VerifyExitCodeAndMessage creates an exit handler which verifies that the program will try to exit execution with the specified exit code and message.