Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PanicTB ¶
func PanicTB() *panicTB
PanicTB is an implementation for testing.TB that panics when an error is logged or FailNow is called. This is useful to inject into test helpers in example tests where no *testing.T is available.
If env is set with `RIVER_DEBUG=true`, output is logged to os.Stderr (Stderr instead of Stdout to not interfere with example test output).
Doesn't fully implement testing.TB. Functions where it's used should take the more streamlined TestingTB instead.
func WaitTimeout ¶ added in v0.43.0
WaitTimeout returns a duration broadly appropriate for waiting on an expected event in a test, and which is used for `TestSignal.WaitOrTimeout` in testsignal and `WaitOrTimeout` in riversharedtest. Its main purpose is to allow a little extra leeway in GitHub Actions where we occasionally seem to observe subpar performance which leads to timeouts and test intermittency, while still keeping a tight a timeout for local test runs where this is never a problem.
It lives here instead of riversharedtest so that testsignal, which is compiled into production binaries, can use it without importing riversharedtest and its heavier test-only dependencies.
Types ¶
type JobArgsReflectKind ¶ added in v0.24.0
type JobArgsReflectKind[TKind any] struct{}
JobArgsReflectKind can be embedded on a struct to implement JobArgs such that the job's kind will be the name of TKind. Typically, for convenience TKind will be the same type that does the embedding. Use of JobArgsReflectKind may not be typical, but in combination with WorkFunc, it allows the entirety of a job args and worker pair to be implemented inside the body of a function.
type InFuncWorkFuncArgs struct {
testutil.JobArgsReflectKind[InFuncWorkFuncArgs]
Message `json:"message"`
}
AddWorker(client.config.Workers, WorkFunc(func(ctx context.Context, job *Job[WorkFuncArgs]) error {
...
Its major downside compared to a normal JobArgs implementation is that it's possible to easily break things accidentally by renaming its type, deploying, and then finding that the worker will no longer work any jobs that were inserted before the deploy. It also depends on reflection, which likely makes it marginally slower.
We're not sure yet whether it's appropriate to expose this publicly, so for now we've localized it to the test suite only. When a test case needs a job type that won't be reused, it's preferable to make use of JobArgsReflectKind so the type doesn't pollute the global namespace.
func (JobArgsReflectKind[TKind]) Kind ¶ added in v0.24.0
func (a JobArgsReflectKind[TKind]) Kind() string
type MockT ¶ added in v0.22.0
type MockT struct {
Failed bool
// contains filtered or unexported fields
}
MockT mocks TestingTB. It's used to let us verify our test helpers.
type TestingTB ¶
type TestingTB interface {
Errorf(format string, args ...any)
FailNow()
Helper()
Log(args ...any)
Logf(format string, args ...any)
Name() string
}
TestingTB is an interface wrapper around *testing.T that's implemented by all of *testing.T, *testing.F, and *testing.B.
It's used internally to verify that River's test assertions are working as expected.