summaryrefslogtreecommitdiff
path: root/testrig/util.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-11-14 15:57:25 +0100
committerLibravatar GitHub <noreply@github.com>2023-11-14 15:57:25 +0100
commit4ee436e98a3351d9568c4a018bd2de34c218e9a6 (patch)
tree4b919150266fb327805f78663e9e705179598a7b /testrig/util.go
parent[bugfix] Update poll delete/update db queries (#2361) (diff)
downloadgotosocial-4ee436e98a3351d9568c4a018bd2de34c218e9a6.tar.xz
[bugfix] process account delete side effects in serial, not in parallel (#2360)
* [bugfix] process account delete side effects in serial, not in parallel * StartWorkers / StartNoopWorkers for tests * undo testrig trace logging * log errors instead of immediately returning
Diffstat (limited to 'testrig/util.go')
-rw-r--r--testrig/util.go19
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()