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
- Variables
- func ArrayToString(tag string, iface interface{}) string
- func BindCurrentTestSetup(set *testing.T)
- func CurrentTestSetup() *testing.T
- func FilePathInsideTempDir(pathInsideTempFolder string) string
- func ReportTestFailed(msg string, args ...interface{})
- func ReportTestIsNotAbleToTest(report string, args ...interface{})
- func ResetTempFolder(testSubFolder *string) string
- func TempFolderPath() string
- func TestName() string
Constants ¶
const ( DefaultDataDirname = "test.data" DefaultDBFileName = "test.dcrdata.sqlt.db" )
Variables ¶
var PanicOnTestFailure = false
PanicOnTestFailure indicates if a stake trace should be printed on test failure.
var PanicOnTestSetupFailure = true
PanicOnTestSetupFailure indicates if test setup failure should cause a panic.
var UseSpewToPrettyPrintArrays = true
UseSpewToPrettyPrintArrays indicates that the go-spew package should be used to pretty print arrays.
Functions ¶
func ArrayToString ¶
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 ¶
BindCurrentTestSetup assigns the active testing framework.
func CurrentTestSetup ¶
CurrentTestSetup returns the active test setup.
func FilePathInsideTempDir ¶
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 ¶
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.
Types ¶
This section is empty.