# README
Testament
For all your testing needs.
Introduction
These are common tools we usually use in our tests.
Function | Description |
---|---|
AssertInError | Check if an error is found in a deeply nested errors |
RandomString | Generates a randomly generated string by given length |
GetFreeOpenPort | Returns a port that is already claimed. |
GetFreePort | Returns a random open port. |
RandomString | Returns a randomly generates string with the length of count. |
RandomLowerString | Returns a randomly generates lower-cased string with a maximum length. |
StringSlice | Return a string slice with the provided length. |
RandomStringSlice | Return a random string slice with maximum length. |
IntSlice | Returns a slice of int elements with the provided length. |
RandIntSlice | Returns a slice of int elements with random length of less than n. |
Int32Slice | |
RandInt32Slice | |
Int64Slice | |
RandInt64Slice | |
IntSliceComparer | Is a go-cmp comparer that doesn't care if the slices are not sorted. |
Int32SliceComparer | |
Int64SliceComparer | |
StringSliceComparer | |
RandomEmailAddress | Returns a valid random email address. |
Development
Prerequisite
This project supports Go >= 1.18
. To run targets from the Makefile
you need
to install GNU make.
In order to install dependencies:
make dependencies
This also installs reflex to help with development process.
Running Tests
To watch for file changes and run unit_test:
make unit_test_watch
# or to run them with race flag:
make unit_test_race_watch
There is also a integration_test
target for running integration tests.
Make Examples
make # shows help on targets.
make unit_test
make unit_test run=TestMyTest # runs a specific test with regexp.
make unit_test dir=./path/... # runs tests in a package.
make unit_test dir=./path/... run=TestSomethingElse
Please see the Makefile for more targets.
# Functions
AssertInError returns true if the needle is found in stack, which is created either with pkg/errors help, the multierror or Go's error wrap.
AssertIsCode is a helper to assert the err error contains the code.
GetFreeOpenPort returns a port that is already claimed.
GetFreePort returns a random open port.
Int32Slice returns a slice of int32 elements with provided length.
Int64Slice returns a slice of int64 elements with provided length.
IntSlice returns a slice of int elements with the provided length.
RandInt32Slice returns a slice of int32 elements with random length of less than n.
RandInt64Slice returns a slice of int64 elements with random length of less than n.
RandIntSlice returns a slice of int elements with random length of less than n.
RandomEmailAddress returns a random email address.
RandomLowerString returns a randomly generates lower-cased string with the length of count.
RandomS3Filename returns a random S3 filename with a subfolder.
RandomString returns a randomly generates string with the length of count.
RandomStringSlice return a random string slice with maximum length of to.
RandUint32Slice returns a slice of uint32 elements with random length of less than n.
RandUint64Slice returns a slice of uint64 elements with random length of less than n.
RandUintSlice returns a slice of uint elements with random length of less than n.
StringSlice return a string slice with the provided length.
Uint32Slice returns a slice of uint32 elements with provided length.
Uint64Slice returns a slice of uint64 elements with provided length.
UintSlice returns a slice of uint elements with the provided length.
# Variables
Int32SliceComparer is a go-cmp comparer that doesn't care if the slices in question is not sorted.
Int64SliceComparer is a go-cmp comparer that doesn't care if the slices in question is not sorted.
IntSliceComparer is a go-cmp comparer that doesn't care if the slices in question is not sorted.
StringSliceComparer is a go-cmp comparer that doesn't care if the slices in question is not sorted.
Uint32SliceComparer is a go-cmp comparer that doesn't care if the slices in question is not sorted.
Uint64SliceComparer is a go-cmp comparer that doesn't care if the slices in question is not sorted.