testingx

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must(t FatalReporter, err error, prefix string, args ...interface{})

Must allows the rtx.Must pattern within a unit test and will call t.Fatal if passed a non-nil error. The fatal message is specified as the prefix argument. If any further args are passed, then the prefix will be treated as a format string.

The main purpose of this function is to turn the common pattern of:

err := Func()
if err != nil {
    t.Fatalf("Helpful message (error: %v)", err)
}

into a simplified pattern of:

Must(t, Func(), "Helpful message")

This has the benefit of using fewer lines and verifying unit tests are "correct by inspection".

func MustReadFile added in v0.1.59

func MustReadFile(t FatalReporter, path string) []byte

MustReadFile will read the file under the input `path` and return the array of bytes. If it fails, it will call t.Fatal.

Types

type FatalReporter

type FatalReporter interface {
	Fatal(args ...interface{})
	Helper()
}

FatalReporter defines the interface for reporting a fatal test.

Jump to

Keyboard shortcuts

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