Documentation
¶
Overview ¶
Package tstr provides testing framework for Go programs that simplifies testing with test dependencies.
Index ¶
Constants ¶
const ( ErrStartFailed = strerr.Error("failed to start test dependencies") ErrStopFailed = strerr.Error("failed to stop test dependencies") )
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run runs the test with the given options. Options are applied in the order they are passed. One of the options must provide the test function.
Options that provide the test function:
- WithM
- WithFn
- WithTable
func RunMain ¶
RunMain is a convinience wrapper around Run that can be used inside TestMain. RunMain applies automatically WithM option which calls m.Run. Also os.Exit is called with non-zero exit code if Run returns any error.
Example:
func TestMain(m *testing.M) { tstr.RunMain(m, tstr.WithDeps(MyDependency())) }
Types ¶
type Dependency ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
func NewRunner ¶
func NewRunner(rr ...Dependency) *Runner
NewRunner creates a new Runner with the given dependencies. The dependencies will be started in the order they are provided and stopped in reverse order. If any of the dependencies fail to start, the rest of the dependencies will not be started. If any of the dependencies fail to stop, the rest of the dependencies will still be stopped. Start method should be non-blocking and return immediately after starting the dependency. Ready method should block until the dependency is ready to be used. Stop method should block until the dependency is stopped.
func (*Runner) Start ¶
Start starts the dependencies in the order they were provided and waits for them to be ready. Next dependency will not be started if the previous one fails to start or become ready. Stop should be always called after Start, even if Start fails. That way all the started dependencies will be stopped.
type Tester ¶
type Tester struct {
// contains filtered or unexported fields
}
Directories
¶
Path | Synopsis |
---|---|
dep
|
|
container
Package container provides a wrapper around the testcontainers-go library to simplify container management in tests.
|
Package container provides a wrapper around the testcontainers-go library to simplify container management in tests. |
Package strerr provides string error type that allows declaring errors as constants unlike Go's own errors.New which uses privete struct type.
|
Package strerr provides string error type that allows declaring errors as constants unlike Go's own errors.New which uses privete struct type. |