summaryrefslogtreecommitdiff
path: root/internal/api/s2s/user/inboxpost_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-08-31 17:31:21 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-31 17:31:21 +0200
commit0245c606d77c8b99833ccc2c0923a298fb482236 (patch)
tree16311e89656894f09cfaeb8b0f21b5ac9e4de502 /internal/api/s2s/user/inboxpost_test.go
parent[feature] add rate limit middleware (#741) (diff)
downloadgotosocial-0245c606d77c8b99833ccc2c0923a298fb482236.tar.xz
[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
Diffstat (limited to 'internal/api/s2s/user/inboxpost_test.go')
-rw-r--r--internal/api/s2s/user/inboxpost_test.go17
1 files changed, 9 insertions, 8 deletions
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 := &gtsmodel.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 := &gtsmodel.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)