diff options
Diffstat (limited to 'testrig/util.go')
-rw-r--r-- | testrig/util.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/testrig/util.go b/testrig/util.go index c2360dc9e..9e5987065 100644 --- a/testrig/util.go +++ b/testrig/util.go @@ -29,13 +29,16 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/messages" tlprocessor "github.com/superseriousbusiness/gotosocial/internal/processing/timeline" + wprocessor "github.com/superseriousbusiness/gotosocial/internal/processing/workers" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/timeline" "github.com/superseriousbusiness/gotosocial/internal/typeutils" "github.com/superseriousbusiness/gotosocial/internal/visibility" ) -func StartWorkers(state *state.State) { +// Starts workers on the provided state using noop processing functions. +// Useful when you *don't* want to trigger side effects in a test. +func StartNoopWorkers(state *state.State) { state.Workers.EnqueueClientAPI = func(context.Context, ...messages.FromClientAPI) {} state.Workers.EnqueueFediAPI = func(context.Context, ...messages.FromFediAPI) {} state.Workers.ProcessFromClientAPI = func(context.Context, messages.FromClientAPI) error { return nil } @@ -47,6 +50,20 @@ func StartWorkers(state *state.State) { _ = state.Workers.Media.Start(1, 10) } +// Starts workers on the provided state using processing functions from the given +// workers processor. Useful when you *do* want to trigger side effects in a test. +func StartWorkers(state *state.State, wProcessor *wprocessor.Processor) { + state.Workers.EnqueueClientAPI = wProcessor.EnqueueClientAPI + state.Workers.EnqueueFediAPI = wProcessor.EnqueueFediAPI + state.Workers.ProcessFromClientAPI = wProcessor.ProcessFromClientAPI + state.Workers.ProcessFromFediAPI = wProcessor.ProcessFromFediAPI + + _ = state.Workers.Scheduler.Start() + _ = state.Workers.ClientAPI.Start(1, 10) + _ = state.Workers.Federator.Start(1, 10) + _ = state.Workers.Media.Start(1, 10) +} + func StopWorkers(state *state.State) { _ = state.Workers.Scheduler.Stop() _ = state.Workers.ClientAPI.Stop() |