...

Package ritesting

import "github.com/dsoprea/go-utility/v2/testing"
Overview
Index

Overview ▾

func DisableMarshaledExits

func DisableMarshaledExits()

DisableMarshaledExits disables exit marshaling.

func EnableMarshaledExits

func EnableMarshaledExits()

EnableMarshaledExits enables exit marshaling.

func Exit

func Exit(returnCode int)

Exit will marshal an exit into a panic if marshaling is turned on. If not turned on, forward through to `os.Exit()`.

func IsTtyRedirected

func IsTtyRedirected() bool

IsTtyRedirected returns whether the TTY is currently redirected.

func RedirectTty

func RedirectTty()

RedirectTty redirects STDIN, STDOUT, and STDERR to alternative resources. This allows us to create unit-tests for executables by directly calling their main() entrypoints.

func RestoreAndDumpTty

func RestoreAndDumpTty()

RestoreAndDumpTty restores original TTY resources but not before grabbing their screen output and then printing it before returning.

func RestoreTty

func RestoreTty()

RestoreTty restores original TTY resources.

func StderrReader

func StderrReader() *os.File

StderrReader returns a reader that can be used to read STDERR output (if redirected).

func StdinWriter

func StdinWriter() *os.File

StdinWriter returns a writer that can be used to feed STDIN data (if redirected).

func StdoutReader

func StdoutReader() *os.File

StdoutReader returns a reader that can be used to read STDOUT output (if redirected).