diff options
author | 2022-08-31 17:31:21 +0200 | |
---|---|---|
committer | 2022-08-31 17:31:21 +0200 | |
commit | 0245c606d77c8b99833ccc2c0923a298fb482236 (patch) | |
tree | 16311e89656894f09cfaeb8b0f21b5ac9e4de502 /internal/federation/federatingactor_test.go | |
parent | [feature] add rate limit middleware (#741) (diff) | |
download | gotosocial-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/federation/federatingactor_test.go')
-rw-r--r-- | internal/federation/federatingactor_test.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/internal/federation/federatingactor_test.go b/internal/federation/federatingactor_test.go index 59687345a..bab38abe2 100644 --- a/internal/federation/federatingactor_test.go +++ b/internal/federation/federatingactor_test.go @@ -115,10 +115,22 @@ func (suite *FederatingActorTestSuite) TestSendRemoteFollower() { suite.NotNil(activity) // because we added 1 remote follower for zork, there should be a url in sentMessage - suite.Len(httpClient.SentMessages, 1) - msg, ok := httpClient.SentMessages[testRemoteAccount.InboxURI] - suite.True(ok) - suite.Equal(`{"@context":"https://www.w3.org/ns/activitystreams","actor":"http://localhost:8080/users/the_mighty_zork","id":"http://localhost:8080/whatever_some_create","object":{"attributedTo":"http://localhost:8080/users/the_mighty_zork","content":"boobies","id":"http://localhost:8080/users/the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5","published":"2022-06-02T12:22:21+02:00","tag":[],"to":"http://localhost:8080/users/the_mighty_zork/followers","type":"Note","url":"http://localhost:8080/@the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5"},"published":"2022-06-02T12:22:21+02:00","to":"http://localhost:8080/users/the_mighty_zork/followers","type":"Create"}`, string(msg)) + var sent [][]byte + if !testrig.WaitFor(func() bool { + sentI, ok := httpClient.SentMessages.Load(testRemoteAccount.InboxURI) + if ok { + sent, ok = sentI.([][]byte) + if !ok { + panic("SentMessages entry was not []byte") + } + return true + } + return false + }) { + suite.FailNow("timed out waiting for message") + } + + suite.Equal(`{"@context":"https://www.w3.org/ns/activitystreams","actor":"http://localhost:8080/users/the_mighty_zork","id":"http://localhost:8080/whatever_some_create","object":{"attributedTo":"http://localhost:8080/users/the_mighty_zork","content":"boobies","id":"http://localhost:8080/users/the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5","published":"2022-06-02T12:22:21+02:00","tag":[],"to":"http://localhost:8080/users/the_mighty_zork/followers","type":"Note","url":"http://localhost:8080/@the_mighty_zork/statuses/01G1TR6BADACCZWQMNF9X21TV5"},"published":"2022-06-02T12:22:21+02:00","to":"http://localhost:8080/users/the_mighty_zork/followers","type":"Create"}`, string(sent[0])) } func TestFederatingActorTestSuite(t *testing.T) { |