testutil

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

package testutil provides some helper functions to be used in unit tests.

package testutil provides convenience functions and types for testing.

Index

Constants

View Source
const (
	DefaultDataDirname = "test.data"
	DefaultDBFileName  = "test.dcrdata.sqlt.db"
)

Variables

View Source
var PanicOnTestFailure = false

PanicOnTestFailure indicates if a stake trace should be printed on test failure.

View Source
var PanicOnTestSetupFailure = true

PanicOnTestSetupFailure indicates if test setup failure should cause a panic.

View Source
var UseSpewToPrettyPrintArrays = true

UseSpewToPrettyPrintArrays indicates that the go-spew package should be used to pretty print arrays.

Functions

func ArrayToString

func ArrayToString(tag string, iface interface{}) string

ArrayToString converts any array into pretty-print string unless UseSpewToPrettyPrintArrays flag signals to use the spew library

Format:

---(%tag)[%arraySize]---

(0) %valueAtIndex0
(1) %valueAtIndex1
(2) %valueAtIndex2
(3) %valueAtIndex3
...

Example call: ArrayToString("array",[5]int{14234, 42, -1, 1000, 5}) Output:

---(array)[5]---
       (0) 14234
       (1) 42
       (2) -1
       (3) 1000
       (4) 5

func BindCurrentTestSetup

func BindCurrentTestSetup(set *testing.T)

BindCurrentTestSetup assigns the active testing framework.

func CurrentTestSetup

func CurrentTestSetup() *testing.T

CurrentTestSetup returns the active test setup.

func FilePathInsideTempDir

func FilePathInsideTempDir(pathInsideTempFolder string) string

FilePathInsideTempDir creates a path to a file inside the temp directory.

func ReportTestFailed

func ReportTestFailed(msg string, args ...interface{})

ReportTestFailed called by test-code to indicate the code failed the test. ReportTestFailed calls testing.T.Fatalf() for tests executed with go-test. Otherwise it brings attention on a bug with the panic(). Ideally this should happen when the test-check was performed by an assert() call in a running program and revealed unacceptable behaviour during debugging or in the test-net.

func ReportTestIsNotAbleToTest

func ReportTestIsNotAbleToTest(report string, args ...interface{})

ReportTestIsNotAbleToTest called on failure in a test setup Indicates that test needs to be fixed

func ResetTempFolder

func ResetTempFolder(testSubFolder *string) string

ResetTempFolder ensures we run our test in a clean room. Removes all files created by any previous tests in the temp directory. Returns the full test folder path.

func TempFolderPath

func TempFolderPath() string

TempFolderPath returns path of a temporary directory used by these tests to store data.

func TestName

func TestName() string

TestName returns the name of the active test setup.

Types

This section is empty.

Jump to

Keyboard shortcuts

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