Documentation
¶
Index ¶
- Constants
- func ArrayToString(tag string, iface interface{}) string
- func AssertNotEmpty(tag string, value string)
- func AssertNotNil(tag string, value interface{})
- func AssertTrue(tag string, value bool)
- func CheckTestSetupMalfunction(err error)
- func D(tag string, message ...interface{})
- func DeRegisterDisposableAsset(resource LeakyAsset)
- func Debug(tag string, message ...interface{})
- func DeleteFile(file string)
- func E(tag string, message ...interface{})
- func Error(tag string, message ...interface{})
- func FileExists(path string) bool
- func ListContainsString(list []string, a string) bool
- func MakeDirs(dir string)
- func RegisterDisposableAsset(resource LeakyAsset)
- func ReportTestSetupMalfunction(malfunction error) error
- func S(tag string, message ...interface{})
- func Sleep(milliseconds int64)
- func Spew(tag string, message ...interface{})
- func VerifyNoAssetsLeaked()
- func WaitForFile(file string, maxSecondsToWait int)
- type DefaultLogPrinter
- type LeakyAsset
- type LeakyAssetsList
- type LogPrinterComponent
- type Pool
- type Spawnable
- type Spawner
- type TempDirHandler
Constants ¶
const ( ERROR = "com.jfixby.scarabei.log.error" DEBUG = "com.jfixby.scarabei.log.debug" SPEW = "com.jfixby.scarabei.log.spew" )
Variables ¶
This section is empty.
Functions ¶
func ArrayToString ¶
ArrayToString converts any array into pretty-print string
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 AssertNotEmpty ¶
AssertNotEmpty checks and reports if given string is empty
func AssertNotNil ¶
func AssertNotNil(tag string, value interface{})
AssertNotNil checks and reports if given variable is nil
func AssertTrue ¶
AssertTrue checks and reports if given variable is false
func CheckTestSetupMalfunction ¶
func CheckTestSetupMalfunction(err error)
CheckTestSetupMalfunction reports error when one is present
func DeRegisterDisposableAsset ¶
func DeRegisterDisposableAsset(resource LeakyAsset)
DeRegisterDisposableAsset removes disposable asset from list Does not tolerate multiple removals of the same element
func DeleteFile ¶
func DeleteFile(file string)
DeleteFile ensures file was deleted reports test setup malfunction otherwise
func FileExists ¶
FileExists returns true when file exists, and false otherwise
func ListContainsString ¶
ListContainsString returns true when the list contains target string
func MakeDirs ¶
func MakeDirs(dir string)
MakeDirs ensures target folder and all it's parents exist. As opposed to the os.Mkdir will not fail due to a lack of unix permissions.
func RegisterDisposableAsset ¶
func RegisterDisposableAsset(resource LeakyAsset)
RegisterDisposableAsset registers disposable asset Does not tolerate multiple appends of the same element
func ReportTestSetupMalfunction ¶
ReportTestSetupMalfunction is used to bring attention to undesired program behaviour. This function is expected to be called never. The fact that it is called indicates a serious bug in the test setup and requires investigation.
func Sleep ¶
func Sleep(milliseconds int64)
Sleep pauses the current goroutine for at least the target milliseconds.
func VerifyNoAssetsLeaked ¶
func VerifyNoAssetsLeaked()
VerifyNoAssetsLeaked checks all leaky assets were properly disposed. Crashes if not. Should be called before test setup exit.
func WaitForFile ¶
WaitForFile sleeps until target file is created or timeout is reached
Types ¶
type DefaultLogPrinter ¶
type DefaultLogPrinter struct { }
func (*DefaultLogPrinter) Debug ¶
func (*DefaultLogPrinter) Debug(msg string)
func (*DefaultLogPrinter) Error ¶
func (*DefaultLogPrinter) Error(msg string)
type LeakyAsset ¶
type LeakyAsset interface {
Dispose()
}
LeakyAsset is a handler for disposable assets like external processes and temporary directories.
type LeakyAssetsList ¶
type LeakyAssetsList struct {
// contains filtered or unexported fields
}
LeakyAssetsList keeps track of leaky assets to ensure their proper disposal before test framework exit.
LeakyAssetsList implements a stack of leaky assets. Ideally assets suppose to be disposed in reverse order to avoid conflicts. Stack helps with that. Structure: [head>=(0)=(1)=.....=(n-1)=<tail] The nodesMap directs given asset to corresponding node for fast search
func (*LeakyAssetsList) Add ¶
func (list *LeakyAssetsList) Add(resource LeakyAsset)
Add element to the list
func (*LeakyAssetsList) Contains ¶
func (list *LeakyAssetsList) Contains(resource LeakyAsset) bool
Contains returns true if element is present in the list
func (*LeakyAssetsList) Remove ¶
func (list *LeakyAssetsList) Remove(resource LeakyAsset)
Remove element from the list
func (*LeakyAssetsList) Size ¶
func (list *LeakyAssetsList) Size() int
Size of the leaky assets list
type LogPrinterComponent ¶
var LogPrinter LogPrinterComponent = &DefaultLogPrinter{}
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool offers management for reusable resources.
func (*Pool) DisposeAll ¶
func (pool *Pool) DisposeAll()
DisposeAll disposes all instances in the poolCache
func (*Pool) InitTags ¶
InitTags ensures the poolCache will immediately resolve tags from the given list for the future calls.
func (*Pool) ObtainSpawnable ¶
ObtainSpawnable returns reusable Spawnable instance upon request, creates a new instance when required and stores it in the poolCache for the following calls
func (*Pool) ObtainSpawnableConcurrentSafe ¶
ObtainSpawnableConcurrentSafe is the ObtainSpawnable but safe for concurrent access.
type Spawner ¶
type Spawner interface { // NewInstance returns a new freshly created Spawnable instance NewInstance(spawnableName string) Spawnable // NameForTag defines a policy for mapping input tags to Spawnable names // for the poolCache NameForTag(tag string) string // Dispose should take care of Spawnable instance disposal Dispose(spawnableToDispose Spawnable) error }
Spawner manages a new Spawnable instance creation and disposal
type TempDirHandler ¶
type TempDirHandler struct {
// contains filtered or unexported fields
}
TempDirHandler offers temporary directories management.
func NewTempDir ¶
func NewTempDir(targetParent string, targetName string) *TempDirHandler
NewTempDir creates new immutable instance of the TempDirHandler.
func (*TempDirHandler) Dispose ¶
func (t *TempDirHandler) Dispose()
Dispose is required for TempDirHandler to implement LeakyAsset
func (*TempDirHandler) Exists ¶
func (t *TempDirHandler) Exists() bool
Exists returns true when target exists.
func (*TempDirHandler) MakeDir ¶
func (t *TempDirHandler) MakeDir() *TempDirHandler
MakeDir ensures target folder and all it's parents exist. Registers created folder as a leaky asset.
func (*TempDirHandler) Path ¶
func (t *TempDirHandler) Path() string
Path string of the temp folder.