diff options
Diffstat (limited to 'internal/typeutils/converter_test.go')
-rw-r--r-- | internal/typeutils/converter_test.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/internal/typeutils/converter_test.go b/internal/typeutils/converter_test.go index 88c0256c8..d92a30c13 100644 --- a/internal/typeutils/converter_test.go +++ b/internal/typeutils/converter_test.go @@ -22,6 +22,7 @@ import ( "github.com/superseriousbusiness/activity/streams/vocab" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" + "github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/typeutils" "github.com/superseriousbusiness/gotosocial/testrig" @@ -482,13 +483,17 @@ type TypeUtilsTestSuite struct { typeconverter typeutils.TypeConverter } -func (suite *TypeUtilsTestSuite) SetupSuite() { +func (suite *TypeUtilsTestSuite) SetupTest() { suite.state.Caches.Init() testrig.InitTestConfig() testrig.InitTestLog() suite.db = testrig.NewTestDB(&suite.state) + suite.state.DB = suite.db + storage := testrig.NewInMemoryStorage() + suite.state.Storage = storage + suite.testAccounts = testrig.NewTestAccounts() suite.testStatuses = testrig.NewTestStatuses() suite.testAttachments = testrig.NewTestAttachments() @@ -497,13 +502,23 @@ func (suite *TypeUtilsTestSuite) SetupSuite() { suite.testReports = testrig.NewTestReports() suite.testMentions = testrig.NewTestMentions() suite.typeconverter = typeutils.NewConverter(suite.db) -} -func (suite *TypeUtilsTestSuite) SetupTest() { - suite.state.Caches.Init() // reset testrig.StandardDBSetup(suite.db, nil) } func (suite *TypeUtilsTestSuite) TearDownTest() { testrig.StandardDBTeardown(suite.db) + testrig.StopWorkers(&suite.state) +} + +// GetProcessor is a utility function that instantiates a processor. +// Useful when a test in the test suite needs to change some state. +func (suite *TypeUtilsTestSuite) GetProcessor() *processing.Processor { + testrig.StartWorkers(&suite.state) + httpClient := testrig.NewMockHTTPClient(nil, "../../testrig/media") + transportController := testrig.NewTestTransportController(&suite.state, httpClient) + mediaManager := testrig.NewTestMediaManager(&suite.state) + federator := testrig.NewTestFederator(&suite.state, transportController, mediaManager) + emailSender := testrig.NewEmailSender("../../web/template/", nil) + return testrig.NewTestProcessor(&suite.state, federator, emailSender, mediaManager) } |