diff options
author | 2023-11-14 15:57:25 +0100 | |
---|---|---|
committer | 2023-11-14 15:57:25 +0100 | |
commit | 4ee436e98a3351d9568c4a018bd2de34c218e9a6 (patch) | |
tree | 4b919150266fb327805f78663e9e705179598a7b /testrig | |
parent | [bugfix] Update poll delete/update db queries (#2361) (diff) | |
download | gotosocial-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')
-rw-r--r-- | testrig/mediahandler.go | 2 | ||||
-rw-r--r-- | testrig/processor.go | 6 | ||||
-rw-r--r-- | testrig/util.go | 19 |
3 files changed, 24 insertions, 3 deletions
diff --git a/testrig/mediahandler.go b/testrig/mediahandler.go index d35dca97e..430e87eb0 100644 --- a/testrig/mediahandler.go +++ b/testrig/mediahandler.go @@ -24,6 +24,6 @@ import ( // NewTestMediaManager returns a media handler with the default test config, and the given db and storage. func NewTestMediaManager(state *state.State) *media.Manager { - StartWorkers(state) // ensure started + StartNoopWorkers(state) // ensure started return media.NewManager(state) } diff --git a/testrig/processor.go b/testrig/processor.go index 137934c5e..e8a871422 100644 --- a/testrig/processor.go +++ b/testrig/processor.go @@ -27,10 +27,14 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/typeutils" ) -// NewTestProcessor returns a Processor suitable for testing purposes +// NewTestProcessor returns a Processor suitable for testing purposes. +// The passed in state will have its worker functions set appropriately, +// but the state will not be initialized. func NewTestProcessor(state *state.State, federator *federation.Federator, emailSender email.Sender, mediaManager *media.Manager) *processing.Processor { p := processing.NewProcessor(cleaner.New(state), typeutils.NewConverter(state), federator, NewTestOauthServer(state.DB), mediaManager, state, emailSender) state.Workers.EnqueueClientAPI = p.Workers().EnqueueClientAPI state.Workers.EnqueueFediAPI = p.Workers().EnqueueFediAPI + state.Workers.ProcessFromClientAPI = p.Workers().ProcessFromClientAPI + state.Workers.ProcessFromFediAPI = p.Workers().ProcessFromFediAPI return p } 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() |