From 0245c606d77c8b99833ccc2c0923a298fb482236 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:31:21 +0200 Subject: [chore] Test fixes (#788) * use 'test' value for testrig storage backend * update test dependency * add WaitFor func in testrig * use WaitFor function instead of time.Sleep * tidy up tests * make SentMessages a sync.map * go fmt --- internal/federation/dereferencing/media_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'internal/federation/dereferencing') diff --git a/internal/federation/dereferencing/media_test.go b/internal/federation/dereferencing/media_test.go index 26d5c0c49..1c460b69e 100644 --- a/internal/federation/dereferencing/media_test.go +++ b/internal/federation/dereferencing/media_test.go @@ -20,13 +20,12 @@ package dereferencing_test import ( "context" - "fmt" "testing" - "time" "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/media" + "github.com/superseriousbusiness/gotosocial/testrig" ) type AttachmentTestSuite struct { @@ -128,12 +127,11 @@ func (suite *AttachmentTestSuite) TestDereferenceAttachmentAsync() { suite.NoError(err) attachmentID := processingMedia.AttachmentID() - // wait for the media to finish processing - for finished := processingMedia.Finished(); !finished; finished = processingMedia.Finished() { - time.Sleep(10 * time.Millisecond) - fmt.Printf("\n\nnot finished yet...\n\n") + if !testrig.WaitFor(func() bool { + return processingMedia.Finished() + }) { + suite.FailNow("timed out waiting for media to be processed") } - fmt.Printf("\n\nfinished!\n\n") // now get the attachment from the database attachment, err := suite.db.GetAttachmentByID(ctx, attachmentID) -- cgit v1.3