Documentation
¶
Overview ¶
package testutil provides some helper functions to be used in unit tests.
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
Set this flag "true" to print a stack stace when a test failed
var PanicOnTestSetupFailure = true
Defines what to do on test setup crash
var UseSpewToPrettyPrintArrays = true
Set this flag "true" to use "github.com/davecgh/go-spew/spew" for arrays pretty print
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 deploys GO-Lang/testing framework
func CurrentTestSetup ¶
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 ¶
Ensures we run our test in a clean room. Removes all files created by any of these tests in the temp directory. Returns the 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.