testutils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(from, to string) error

func CopyFile

func CopyFile(from, to string) error

func CreateDir

func CreateDir(rootDir, dir string) error

func CreateFile

func CreateFile(rootDir, filePath string, content []byte) error

func ReplaceStderr

func ReplaceStderr() (restore func(), getOutput func() string)

ReplaceStderr temporarily replaces os.Stderr with a buffer and captures the standard error in a string. Use `defer restore()` to restore the original os.Stderr. Call getOutput once done writing to standard error.

func ReplaceStdout

func ReplaceStdout() (restore func(), getOutput func() string)

ReplaceStdout temporarily replaces os.Stdout with a buffer and captures the standard output in a string. Use `defer restore()` to restore the original os.Stdout. Call getOutput once done writing to standard output.

Types

type Request

type Request struct {
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(method, route string) *Request

func (*Request) RunOnHandler

func (r *Request) RunOnHandler(h http.Handler) *httptest.ResponseRecorder

func (*Request) WithBody

func (r *Request) WithBody(body []byte) *Request

func (*Request) WithHeader

func (r *Request) WithHeader(key, value string) *Request

type TestClock

type TestClock struct {
	// contains filtered or unexported fields
}

func NewTestClock

func NewTestClock(t time.Time, step time.Duration) *TestClock

func (*TestClock) Now

func (c *TestClock) Now() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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