[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
This commit is contained in:
tobi 2022-08-31 17:31:21 +02:00 committed by GitHub
commit 0245c606d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 501 additions and 222 deletions

View file

@ -26,7 +26,6 @@ import (
"os"
"path"
"testing"
"time"
"codeberg.org/gruf/go-store/kv"
"codeberg.org/gruf/go-store/storage"
@ -34,6 +33,7 @@ import (
gtsmodel "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/media"
gtsstorage "github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/testrig"
)
type ManagerTestSuite struct {
@ -360,11 +360,11 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessAsync() {
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")
// fetch the attachment from the database
attachment, err := suite.db.GetAttachmentByID(ctx, attachmentID)