summaryrefslogtreecommitdiff
path: root/internal/typeutils/converter_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-03-31 15:01:29 +0200
committerLibravatar GitHub <noreply@github.com>2023-03-31 15:01:29 +0200
commitd9bbcc60a6cd32282de907a2090c674c4616219e (patch)
treec007cf145ebe24fcc3de420020722a4ea70fb803 /internal/typeutils/converter_test.go
parent[bugfix] Fix relationship not updating 'following' on accept follow request (... (diff)
downloadgotosocial-d9bbcc60a6cd32282de907a2090c674c4616219e.tar.xz
[bugfix] Fix report serialization errors caused by user delete (#1659)
* [bugfix] Fix report serialization errors caused by user delete * fix tests
Diffstat (limited to 'internal/typeutils/converter_test.go')
-rw-r--r--internal/typeutils/converter_test.go23
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)
}