Documentation ¶
Overview ¶
Package helpers (github.com/launchdarkly/go-test-helpers) contains miscellaneous convenience functions for use in test code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolPtr ¶
BoolPtr returns a pointer to a bool value. This is useful within expressions where the value is a literal.
func FilePathExists ¶
FilePathExists is simply a shortcut for using os.Stat to check for a file's or directory's existence.
func Float64Ptr ¶
Float64Ptr returns a pointer to an float64 value. This is useful within expressions where the value is a literal.
func IntPtr ¶
IntPtr returns a pointer to an int value. This is useful within expressions where the value is a literal.
func StrPtr ¶
StrPtr returns a pointer to a string value. This is useful within expressions where the value is a literal.
func Uint64Ptr ¶
Uint64Ptr returns a pointer to a uint64 value. This is useful within expressions where the value is a literal.
func WithCloser ¶
WithCloser executes a function and ensures that the given object's Close() method is always called afterward.
This is simply a way to get more specific control over an object's lifetime than using defer. A test function may wish to ensure that an object is closed before some subsequent actions are taken, rather than at the end of the entire test.
If closing the object fails, an error is logged.
func WithTempFile ¶
func WithTempFile(f func(string))
WithTempFile creates a temporary file, passes its name to the given function, then ensures that the file is deleted.
If for any reason it is not possible to create the file, a panic is raised since the test code cannot continue.
If deletion of the file fails (assuming it has not already been deleted) then an error is logged, but there is no panic.
helpers.WithTempFile(func(path string) { DoSomethingWithTempFile(path) }) // the file is deleted at the end of this block
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package httphelpers contains convenience tools for testing HTTP client code.
|
Package httphelpers contains convenience tools for testing HTTP client code. |
Package ldservices provides HTTP handlers that simulate the behavior of LaunchDarkly service endpoints.
|
Package ldservices provides HTTP handlers that simulate the behavior of LaunchDarkly service endpoints. |
Package testbox provides the ability to run test logic that uses a subset of Go's testing.T methods either inside or outside the regular testing environment.
|
Package testbox provides the ability to run test logic that uses a subset of Go's testing.T methods either inside or outside the regular testing environment. |