testutils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package testutils provides utilities used in tests

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDeepEqual

func AssertDeepEqual(t *testing.T, a interface{}, b interface{}, message string)

AssertDeepEqual fails a test if the actual does not deeply equal the expected

func AssertEqual

func AssertEqual(t *testing.T, a interface{}, b interface{}, message string)

AssertEqual errors a test if the actual does not match the expected

func AssertEqualf added in v0.4.5

func AssertEqualf(t *testing.T, a interface{}, b interface{}, message string)

AssertEqualf fails a test if the actual does not match the expected

func AssertNotEqual

func AssertNotEqual(t *testing.T, a interface{}, b interface{}, message string)

AssertNotEqual fails a test if the actual matches the expected

func CopyFixture added in v0.4.5

func CopyFixture(ctx infra.DnoteCtx, fixturePath string, filename string)

CopyFixture writes the content of the given fixture to the filename inside the dnote dir

func InitEnv added in v0.4.5

func InitEnv(t *testing.T, dnotehomePath string, fixturePath string, migrated bool) infra.DnoteCtx

InitEnv sets up a test env and returns a new dnote context

func IsEqualJSON added in v0.4.3

func IsEqualJSON(s1, s2 []byte) (bool, error)

IsEqualJSON deeply compares two JSON byte slices

func Login added in v0.6.0

func Login(t *testing.T, ctx *infra.DnoteCtx)

Login simulates a logged in user by inserting credentials in the local database

func MustExec added in v0.4.5

func MustExec(t *testing.T, message string, db *infra.DB, query string, args ...interface{}) sql.Result

MustExec executes the given SQL query and fails a test if an error occurs

func MustMarshalJSON added in v0.4.5

func MustMarshalJSON(t *testing.T, v interface{}) []byte

MustMarshalJSON marshalls the given interface into JSON. If there is any error, it fails the test.

func MustScan added in v0.4.5

func MustScan(t *testing.T, message string, row *sql.Row, args ...interface{})

MustScan scans the given row and fails a test in case of any errors

func MustUnmarshalJSON added in v0.4.5

func MustUnmarshalJSON(t *testing.T, data []byte, v interface{})

MustUnmarshalJSON marshalls the given interface into JSON. If there is any error, it fails the test.

func NewDnoteCmd added in v0.4.5

func NewDnoteCmd(ctx infra.DnoteCtx, binaryName string, arg ...string) (*exec.Cmd, *bytes.Buffer, *bytes.Buffer, error)

NewDnoteCmd returns a new Dnote command and a pointer to stderr

func ReadFile

func ReadFile(ctx infra.DnoteCtx, filename string) []byte

ReadFile reads the content of the file with the given name in dnote dir

func ReadFileAbs added in v0.4.0

func ReadFileAbs(relpath string) []byte

ReadFileAbs reads the content of the file with the given file path by resolving it as an absolute path

func ReadJSON

func ReadJSON(path string, destination interface{})

ReadJSON reads JSON fixture to the struct at the destination address

func RunDnoteCmd added in v0.4.5

func RunDnoteCmd(t *testing.T, ctx infra.DnoteCtx, binaryName string, arg ...string)

RunDnoteCmd runs a dnote command

func Setup1 added in v0.4.5

func Setup1(t *testing.T, ctx infra.DnoteCtx)

Setup1 sets up a dnote env #1 dnote4.json

func Setup2 added in v0.4.5

func Setup2(t *testing.T, ctx infra.DnoteCtx)

Setup2 sets up a dnote env #2 dnote3.json

func Setup3 added in v0.4.5

func Setup3(t *testing.T, ctx infra.DnoteCtx)

Setup3 sets up a dnote env #1 dnote1.json

func Setup4 added in v0.4.5

func Setup4(t *testing.T, ctx infra.DnoteCtx)

Setup4 sets up a dnote env #1 dnote2.json

func TeardownEnv added in v0.4.5

func TeardownEnv(ctx infra.DnoteCtx)

TeardownEnv cleans up the test env represented by the given context

func UserConfirm added in v0.4.5

func UserConfirm(stdin io.WriteCloser) error

UserConfirm simulates confirmation from the user by writing to stdin

func WaitDnoteCmd added in v0.4.5

func WaitDnoteCmd(t *testing.T, ctx infra.DnoteCtx, runFunc func(io.WriteCloser) error, binaryName string, arg ...string)

WaitDnoteCmd runs a dnote command and waits until the command is exited

func WriteFile

func WriteFile(ctx infra.DnoteCtx, content []byte, filename string)

WriteFile writes a file with the given content and filename inside the dnote dir

Types

This section is empty.

Jump to

Keyboard shortcuts

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