Documentation ¶
Overview ¶
Package testutils provides utilities used in tests
Index ¶
- func AssertDeepEqual(t *testing.T, a interface{}, b interface{}, message string)
- func AssertEqual(t *testing.T, a interface{}, b interface{}, message string)
- func AssertEqualf(t *testing.T, a interface{}, b interface{}, message string)
- func AssertNotEqual(t *testing.T, a interface{}, b interface{}, message string)
- func CopyFixture(ctx infra.DnoteCtx, fixturePath string, filename string)
- func InitEnv(t *testing.T, dnotehomePath string, fixturePath string, migrated bool) infra.DnoteCtx
- func IsEqualJSON(s1, s2 []byte) (bool, error)
- func Login(t *testing.T, ctx *infra.DnoteCtx)
- func MustExec(t *testing.T, message string, db *infra.DB, query string, args ...interface{}) sql.Result
- func MustMarshalJSON(t *testing.T, v interface{}) []byte
- func MustScan(t *testing.T, message string, row *sql.Row, args ...interface{})
- func MustUnmarshalJSON(t *testing.T, data []byte, v interface{})
- func NewDnoteCmd(ctx infra.DnoteCtx, binaryName string, arg ...string) (*exec.Cmd, *bytes.Buffer, *bytes.Buffer, error)
- func ReadFile(ctx infra.DnoteCtx, filename string) []byte
- func ReadFileAbs(relpath string) []byte
- func ReadJSON(path string, destination interface{})
- func RunDnoteCmd(t *testing.T, ctx infra.DnoteCtx, binaryName string, arg ...string)
- func Setup1(t *testing.T, ctx infra.DnoteCtx)
- func Setup2(t *testing.T, ctx infra.DnoteCtx)
- func Setup3(t *testing.T, ctx infra.DnoteCtx)
- func Setup4(t *testing.T, ctx infra.DnoteCtx)
- func TeardownEnv(ctx infra.DnoteCtx)
- func UserConfirm(stdin io.WriteCloser) error
- func WaitDnoteCmd(t *testing.T, ctx infra.DnoteCtx, runFunc func(io.WriteCloser) error, ...)
- func WriteFile(ctx infra.DnoteCtx, content []byte, filename string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertDeepEqual ¶
AssertDeepEqual fails a test if the actual does not deeply equal the expected
func AssertEqual ¶
AssertEqual errors a test if the actual does not match the expected
func AssertEqualf ¶ added in v0.4.5
AssertEqualf fails a test if the actual does not match the expected
func AssertNotEqual ¶
AssertNotEqual fails a test if the actual matches the expected
func CopyFixture ¶ added in v0.4.5
CopyFixture writes the content of the given fixture to the filename inside the dnote dir
func IsEqualJSON ¶ added in v0.4.3
IsEqualJSON deeply compares two JSON byte slices
func Login ¶ added in v0.6.0
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
MustMarshalJSON marshalls the given interface into JSON. If there is any error, it fails the test.
func MustUnmarshalJSON ¶ added in v0.4.5
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 ReadFileAbs ¶ added in v0.4.0
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
RunDnoteCmd runs a dnote command
func TeardownEnv ¶ added in v0.4.5
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
Types ¶
This section is empty.