pin

package module
v0.0.0-...-9aa2fb4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: Unlicense Imports: 11 Imported by: 30

Documentation

Index

Constants

View Source
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

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

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

func AssertNotEmpty(tag string, value string)

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

func AssertTrue(tag string, value bool)

AssertTrue checks and reports if given variable is false

func CheckTestSetupMalfunction

func CheckTestSetupMalfunction(err error)

CheckTestSetupMalfunction reports error when one is present

func D

func D(tag string, message ...interface{})

func DeRegisterDisposableAsset

func DeRegisterDisposableAsset(resource LeakyAsset)

DeRegisterDisposableAsset removes disposable asset from list Does not tolerate multiple removals of the same element

func Debug

func Debug(tag string, message ...interface{})

func DeleteFile

func DeleteFile(file string)

DeleteFile ensures file was deleted reports test setup malfunction otherwise

func E

func E(tag string, message ...interface{})

func Error

func Error(tag string, message ...interface{})

func FileExists

func FileExists(path string) bool

FileExists returns true when file exists, and false otherwise

func ListContainsString

func ListContainsString(list []string, a string) bool

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

func ReportTestSetupMalfunction(malfunction error) error

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 S

func S(tag string, message ...interface{})

func Sleep

func Sleep(milliseconds int64)

Sleep pauses the current goroutine for at least the target milliseconds.

func Spew

func Spew(tag string, message ...interface{})

func VerifyNoAssetsLeaked

func VerifyNoAssetsLeaked()

VerifyNoAssetsLeaked checks all leaky assets were properly disposed. Crashes if not. Should be called before test setup exit.

func WaitForFile

func WaitForFile(file string, maxSecondsToWait int)

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

type LogPrinterComponent interface {
	Debug(msg string)
	Error(msg string)
}

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool offers management for reusable resources.

func NewPool

func NewPool(spawner Spawner) *Pool

NewPool produces a new Pool instance

func (*Pool) DisposeAll

func (pool *Pool) DisposeAll()

DisposeAll disposes all instances in the poolCache

func (*Pool) InitTags

func (pool *Pool) InitTags(tags []string)

InitTags ensures the poolCache will immediately resolve tags from the given list for the future calls.

func (*Pool) ObtainSpawnable

func (pool *Pool) ObtainSpawnable(tag string) Spawnable

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

func (pool *Pool) ObtainSpawnableConcurrentSafe(tag string) Spawnable

ObtainSpawnableConcurrentSafe is the ObtainSpawnable but safe for concurrent access.

func (*Pool) Size

func (pool *Pool) Size() int

Size returns current number if instances stored in the pool

type Spawnable

type Spawnable interface {
}

Spawnable wraps reusable asset

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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