From f23f04e0b1d117be714bf91d5266dab219ed741e Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 24 Aug 2024 11:49:37 +0200 Subject: [feature] Interaction requests client api + settings panel (#3215) * [feature] Interaction requests client api + settings panel * test accept / reject * fmt * don't pin rejected interaction * use single db model for interaction accept, reject, and request * swaggor * env sharting * append errors * remove ErrNoEntries checks * change intReqID to reqID * rename "pend" to "request" * markIntsPending -> mark interactionsPending * use log instead of returning error when rejecting interaction * empty migration * jolly renaming * make interactionURI unique again * swag grr * remove unnecessary locks * invalidate as last step --- internal/processing/workers/workers_test.go | 88 ++--------------------------- 1 file changed, 5 insertions(+), 83 deletions(-) (limited to 'internal/processing/workers/workers_test.go') diff --git a/internal/processing/workers/workers_test.go b/internal/processing/workers/workers_test.go index 65ed3f6b7..ffd40d8fb 100644 --- a/internal/processing/workers/workers_test.go +++ b/internal/processing/workers/workers_test.go @@ -21,19 +21,18 @@ import ( "context" "github.com/stretchr/testify/suite" - "github.com/superseriousbusiness/gotosocial/internal/cleaner" - "github.com/superseriousbusiness/gotosocial/internal/email" - "github.com/superseriousbusiness/gotosocial/internal/filter/interaction" - "github.com/superseriousbusiness/gotosocial/internal/filter/visibility" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/processing" - "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/stream" - "github.com/superseriousbusiness/gotosocial/internal/typeutils" "github.com/superseriousbusiness/gotosocial/testrig" ) +const ( + rMediaPath = "../../../testrig/media" + rTemplatePath = "../../../web/template" +) + type WorkersTestSuite struct { // standard suite interfaces suite.Suite @@ -56,23 +55,6 @@ type WorkersTestSuite struct { testListEntries map[string]*gtsmodel.ListEntry } -// TestStructs encapsulates structs needed to -// run one test in this package. Each test should -// call SetupTestStructs to get a new TestStructs, -// and defer TearDownTestStructs to close it when -// the test is complete. The reason for doing things -// this way here is to prevent the tests in this -// package from overwriting one another's processors -// and worker queues, which was causing issues -// when running all tests at once. -type TestStructs struct { - State *state.State - Processor *processing.Processor - HTTPClient *testrig.MockHTTPClient - TypeConverter *typeutils.Converter - EmailSender email.Sender -} - func (suite *WorkersTestSuite) SetupSuite() { suite.testTokens = testrig.NewTestTokens() suite.testClients = testrig.NewTestClients() @@ -132,63 +114,3 @@ func (suite *WorkersTestSuite) openStreams(ctx context.Context, processor *proce return streams } - -func (suite *WorkersTestSuite) SetupTestStructs() *TestStructs { - state := state.State{} - - state.Caches.Init() - - db := testrig.NewTestDB(&state) - state.DB = db - - storage := testrig.NewInMemoryStorage() - state.Storage = storage - typeconverter := typeutils.NewConverter(&state) - - testrig.StartTimelines( - &state, - visibility.NewFilter(&state), - typeconverter, - ) - - httpClient := testrig.NewMockHTTPClient(nil, "../../../testrig/media") - httpClient.TestRemotePeople = testrig.NewTestFediPeople() - httpClient.TestRemoteStatuses = testrig.NewTestFediStatuses() - - transportController := testrig.NewTestTransportController(&state, httpClient) - mediaManager := testrig.NewTestMediaManager(&state) - federator := testrig.NewTestFederator(&state, transportController, mediaManager) - oauthServer := testrig.NewTestOauthServer(db) - emailSender := testrig.NewEmailSender("../../../web/template/", nil) - - processor := processing.NewProcessor( - cleaner.New(&state), - typeconverter, - federator, - oauthServer, - mediaManager, - &state, - emailSender, - visibility.NewFilter(&state), - interaction.NewFilter(&state), - ) - - testrig.StartWorkers(&state, processor.Workers()) - - testrig.StandardDBSetup(db, suite.testAccounts) - testrig.StandardStorageSetup(storage, "../../../testrig/media") - - return &TestStructs{ - State: &state, - Processor: processor, - HTTPClient: httpClient, - TypeConverter: typeconverter, - EmailSender: emailSender, - } -} - -func (suite *WorkersTestSuite) TearDownTestStructs(testStructs *TestStructs) { - testrig.StandardDBTeardown(testStructs.State.DB) - testrig.StandardStorageTeardown(testStructs.State.Storage) - testrig.StopWorkers(testStructs.State) -} -- cgit v1.2.3