diff options
Diffstat (limited to 'internal/media')
| -rw-r--r-- | internal/media/manager_test.go | 19 | ||||
| -rw-r--r-- | internal/media/media_test.go | 18 |
2 files changed, 21 insertions, 16 deletions
diff --git a/internal/media/manager_test.go b/internal/media/manager_test.go index 4dc0c4fa2..fb0784034 100644 --- a/internal/media/manager_test.go +++ b/internal/media/manager_test.go @@ -33,6 +33,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/media" "github.com/superseriousbusiness/gotosocial/internal/state" gtsstorage "github.com/superseriousbusiness/gotosocial/internal/storage" + "github.com/superseriousbusiness/gotosocial/testrig" ) type ManagerTestSuite struct { @@ -395,9 +396,6 @@ func (suite *ManagerTestSuite) TestSlothVineProcessBlocking() { // fetch the attachment id from the processing media attachmentID := processingMedia.AttachmentID() - // Give time for processing - time.Sleep(time.Second * 3) - // do a blocking call to fetch the attachment attachment, err := processingMedia.LoadAttachment(ctx) suite.NoError(err) @@ -1027,13 +1025,14 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessAsync() { // fetch the attachment id from the processing media attachmentID := processingMedia.AttachmentID() - // Give time for processing to happen. - time.Sleep(time.Second * 3) - - // fetch the attachment from the database - attachment, err := suite.db.GetAttachmentByID(ctx, attachmentID) - suite.NoError(err) - suite.NotNil(attachment) + // wait for processing to complete + var attachment *gtsmodel.MediaAttachment + if !testrig.WaitFor(func() bool { + attachment, err = suite.db.GetAttachmentByID(ctx, attachmentID) + return err == nil && attachment != nil + }) { + suite.FailNow("timed out waiting for attachment to process") + } // make sure it's got the stuff set on it that we expect // the attachment ID and accountID we expect diff --git a/internal/media/media_test.go b/internal/media/media_test.go index e522fbb90..323f87bf4 100644 --- a/internal/media/media_test.go +++ b/internal/media/media_test.go @@ -25,6 +25,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/storage" "github.com/superseriousbusiness/gotosocial/internal/transport" + "github.com/superseriousbusiness/gotosocial/internal/visibility" "github.com/superseriousbusiness/gotosocial/testrig" ) @@ -41,22 +42,27 @@ type MediaStandardTestSuite struct { testEmojis map[string]*gtsmodel.Emoji } -func (suite *MediaStandardTestSuite) SetupSuite() { +func (suite *MediaStandardTestSuite) SetupTest() { testrig.InitTestConfig() testrig.InitTestLog() + suite.state.Caches.Init() + testrig.StartWorkers(&suite.state) + suite.db = testrig.NewTestDB(&suite.state) suite.storage = testrig.NewInMemoryStorage() suite.state.DB = suite.db suite.state.Storage = suite.storage -} - -func (suite *MediaStandardTestSuite) SetupTest() { - suite.state.Caches.Init() - testrig.StartWorkers(&suite.state) testrig.StandardStorageSetup(suite.storage, "../../testrig/media") testrig.StandardDBSetup(suite.db, nil) + + testrig.StartTimelines( + &suite.state, + visibility.NewFilter(&suite.state), + testrig.NewTestTypeConverter(suite.db), + ) + suite.testAttachments = testrig.NewTestAttachments() suite.testAccounts = testrig.NewTestAccounts() suite.testEmojis = testrig.NewTestEmojis() |
