devtest

package
v0.16.1-0...-3533f93 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DebugLoggingEnabled = os.Getenv("DEBUG_LOG") == "1"
	StubbedArgs         = make(map[string]int)

	ProjectRoot = filepath.Join(filepath.Dir(b), "..", "..")
)

Functions

func DirExists

func DirExists(dirname string) bool

DirExists returns true if a directory exists at the given path.

func EnsurePumaDevDirectory

func EnsurePumaDevDirectory()

EnsurePumaDevDirectory creates ~/.puma-dev if it does not already exist.

func FileExists

func FileExists(filename string) bool

FileExists returns true if a regular file exists at the given path.

func LogDebugf

func LogDebugf(msg string, vars ...interface{})

LogDebugf prints a formatted log message if DEBUG_LOG=1

func MakeDirectoryOrFail

func MakeDirectoryOrFail(t *testing.T, path string) func()

MakeDirectoryOrFail makes a directory or fails the test, returning the path of the directory that was created.

func RemoveAppSymlinkOrFail

func RemoveAppSymlinkOrFail(t *testing.T, name string)

RemoveAppSymlinkOrFail deletes a symlink at ~/.puma-dev/{name} or fails the test.

func RemoveDirectoryOrFail

func RemoveDirectoryOrFail(t *testing.T, path string)

RemoveDirectoryOrFail removes a directory (and its contents) or fails the test.

func SetFlagOrFail

func SetFlagOrFail(t *testing.T, flagName string, flagValue string)

SetFlagOrFail sets the value of a flag or fails the given testing.T

func StubCommandLineArgs

func StubCommandLineArgs(args ...string)

StubCommandLineArgs overrides command arguments to allow flag-based branches to execute. It does not modify os.Args[0] so it can be used for subprocess tests. It also resets all defined flags to their default values, as `flag.Parse()` will not reset non-existent boolean flags if they have been stubbed in other tests.

func WithStdoutCaptured

func WithStdoutCaptured(f func()) string

WithStdoutCaptured executes the passed function and returns a string containing the stdout of the executed function.

func WithWorkingDirectory

func WithWorkingDirectory(path string, f func())

WithWorkingDirectory executes the passed function within the context of the passed working directory path. If the directory does not exist, panic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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