testing

package
v0.0.0-...-83c1a15 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearEnvs

func ClearEnvs(t *testing.T)

ClearEnvs sets all environment variables with the prefix of FUNC_ to empty (unsets) for the duration of the test t and is used when a test needs to completely clear dubbo-related envs prior to running.

func Cwd

func Cwd() (cwd string)

Cwd returns the current working directory or panic if unable to determine.

func FileExists

func FileExists(t *testing.T, filePath string) (bool, error)

FileExists checks whether file on the specified path exists

func Fromtemp

func Fromtemp(t *testing.T) func()

Fromtemp is like Mktemp, but does not bother returing the temp path.

func Mktemp

func Mktemp(t *testing.T) (string, func())

Mktemp creates a temporary directory, CDs the current processes (test) to said directory, and returns the path to said directory. Usage:

path, rm := Mktemp(t)
defer rm()
CWD is now 'path'

errors encountererd fail the current test.

func RunGitServer

func RunGitServer(root string, t *testing.T) (url string)

RunGitServer starts serving git HTTP server and returns its address

func ServeRepo

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

ServeRepo [name] from ./testdata/[name] returning URL at which the named repository is available. Must be called before any helpers which change test working directory such as fromTempDirectory(t)

func Using

func Using(t *testing.T, root string) func()

Using the given path, create it as a new directory and return a deferrable which will remove it. usage:

defer using(t, "testdata/example.com/someExampleTest")()

func WithExecutable

func WithExecutable(t *testing.T, name, goSrc string)

WithExecutable creates an executable of the given name and source in a temp directory which is then added to PATH. Returned is a deferrable which will clean up both the script and PATH.

func Within

func Within(t *testing.T, root string) func()

Within the given root creates the directory, CDs to it, and rturns a closure that when executed (intended in a defer) removes the given dirctory and returns the caller to the initial working directory. usage:

defer within(t, "somedir")()

Types

This section is empty.

Jump to

Keyboard shortcuts

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