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/api/s2s/user/inboxpost_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'internal/api/s2s/user/inboxpost_test.go') diff --git a/internal/api/s2s/user/inboxpost_test.go b/internal/api/s2s/user/inboxpost_test.go index 506fa270c..ff3ec47d3 100644 --- a/internal/api/s2s/user/inboxpost_test.go +++ b/internal/api/s2s/user/inboxpost_test.go @@ -444,14 +444,15 @@ func (suite *InboxPostTestSuite) TestPostDelete() { suite.Empty(b) suite.Equal(http.StatusOK, result.StatusCode) - // sleep for a sec so side effects can process in the background - time.Sleep(2 * time.Second) - - // local account 2 blocked foss_satan, that block should be gone now - testBlock := suite.testBlocks["local_account_2_block_remote_account_1"] - dbBlock := >smodel.Block{} - err = suite.db.GetByID(ctx, testBlock.ID, dbBlock) - suite.ErrorIs(err, db.ErrNoEntries) + if !testrig.WaitFor(func() bool { + // local account 2 blocked foss_satan, that block should be gone now + testBlock := suite.testBlocks["local_account_2_block_remote_account_1"] + dbBlock := >smodel.Block{} + err = suite.db.GetByID(ctx, testBlock.ID, dbBlock) + return suite.ErrorIs(err, db.ErrNoEntries) + }) { + suite.FailNow("timed out waiting for block to be removed") + } // no statuses from foss satan should be left in the database dbStatuses, err := suite.db.GetAccountStatuses(ctx, deletedAccount.ID, 0, false, false, "", "", false, false, false) -- cgit v1.2.3