test

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: CC-BY-4.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyEquals

func BodyEquals(t assert.TestingT, obj interface{}, recorder *httptest.ResponseRecorder)

BodyEquals asserts the content from the response recorder with the encoded json of the provided instance.

func GetProjectDir

func GetProjectDir() string

GetProjectDir returns the correct absolute path of this project.

func JSONEquals

func JSONEquals(t assert.TestingT, obj interface{}, expected string)

JSONEquals asserts the content of the string with the encoded json of the provided instance.

func Tokens

func Tokens(tokens ...string) func() string

Tokens returns a token generation function with takes a series of tokens and output them in order.

func UnreadableReader

func UnreadableReader() io.Reader

UnreadableReader returns an unreadable reader, used to mock IO issues.

func WithUser

func WithUser(ctx *gin.Context, userID uint)

WithUser fake an authentication for testing.

func WithWd

func WithWd(chDir string, f func(origWd string))

WithWd executes a function with the specified working directory.

Types

type TmpDir

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

TmpDir is a handler to temporary directory.

func NewTmpDir

func NewTmpDir(prefix string) TmpDir

NewTmpDir returns a new handle to a tmp dir.

func (TmpDir) Clean

func (c TmpDir) Clean() error

Clean removes the TmpDir.

func (TmpDir) Path

func (c TmpDir) Path(elem ...string) string

Path returns the path to the temporary directory joined by the elements provided.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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