testutil

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

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

Index

Constants

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

Variables

View Source
var PanicOnTestFailure = false

Set this flag "true" to print a stack stace when a test failed

View Source
var PanicOnTestSetupFailure = true

Defines what to do on test setup crash

View Source
var UseSpewToPrettyPrintArrays = true

Set this flag "true" to use "github.com/davecgh/go-spew/spew" for arrays pretty print

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 deploys GO-Lang/testing framework

func CurrentTestSetup

func CurrentTestSetup() *testing.T

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

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.

func TestName

func TestName() string

TestName returns current test name for tests executed with go-test

Types

This section is empty.

Jump to

Keyboard shortcuts

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