testutils

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RuntimeTest func(t *testing.T)

Functions

func PackageDirectory

func PackageDirectory() string

PackageDirectory returns package path of the test's Test...() function. This function works as following:

It traces back the call stack using runtime,
ignoring test utility packages like "test", "test/utils", "testdata" and "runtime,
until it find golang's "testing" package. The last seen package is considered the package of Test...().

Limitation:

  • This function would not work in tests that have their directory ending with "test" and "test/utils" The workaround is to set RuntimeTest to one of the test function.
  • THis function would not work in any "testdata" directory. There is no workaround.

func ProjectDirectory

func ProjectDirectory() string

ProjectDirectory returns the directory of test's project root (directory containing go.mod). Note: this function leverage PackageDirectory(), so same limitation applies

Types

type UUIDPool

type UUIDPool struct {
	Pool    []uuid.UUID
	Current int
}

UUIDPool hold a list of uuid and make sure same uuid is returned each time Pop is called

func NewUUIDPool

func NewUUIDPool(fsys fs.FS, src string) (*UUIDPool, error)

func (*UUIDPool) Pop

func (p *UUIDPool) Pop() (uuid.UUID, error)

Pop return a uuid and increase index by one. This function returns error when index out of bound

func (*UUIDPool) PopOrNew

func (p *UUIDPool) PopOrNew() uuid.UUID

Directories

Path Synopsis
Package golden will contain some utility functions for golden file testing
Package golden will contain some utility functions for golden file testing

Jump to

Keyboard shortcuts

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