devtest

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: BSD-3-Clause Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 LinkAllTestApps

func LinkAllTestApps(t *testing.T, workingDirPath string) func()

func LinkTestApps

func LinkTestApps(t *testing.T, workingDirPath string, testAppsToLink map[string]string) func()

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