summaryrefslogtreecommitdiff
path: root/internal/processing/fromfederator_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing/fromfederator_test.go')
-rw-r--r--internal/processing/fromfederator_test.go51
1 files changed, 32 insertions, 19 deletions
diff --git a/internal/processing/fromfederator_test.go b/internal/processing/fromfederator_test.go
index 86b63dade..8489303e8 100644
--- a/internal/processing/fromfederator_test.go
+++ b/internal/processing/fromfederator_test.go
@@ -482,26 +482,22 @@ func (suite *FromFederatorTestSuite) TestProcessFollowRequestUnlocked() {
})
suite.NoError(err)
- // a notification should be streamed
- var msg *stream.Message
- select {
- case msg = <-wssStream.Messages:
- // fine
- case <-time.After(5 * time.Second):
- suite.FailNow("no message from wssStream")
+ // an accept message should be sent to satan's inbox
+ var sent [][]byte
+ if !testrig.WaitFor(func() bool {
+ sentI, ok := suite.httpClient.SentMessages.Load(originAccount.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(stream.EventTypeNotification, msg.Event)
- suite.NotEmpty(msg.Payload)
- suite.EqualValues([]string{stream.TimelineHome}, msg.Stream)
- notif := &model.Notification{}
- err = json.Unmarshal([]byte(msg.Payload), notif)
- suite.NoError(err)
- suite.Equal("follow", notif.Type)
- suite.Equal(originAccount.ID, notif.Account.ID)
- // an accept message should be sent to satan's inbox
- suite.Len(suite.httpClient.SentMessages, 1)
- acceptBytes := suite.httpClient.SentMessages[originAccount.InboxURI]
accept := &struct {
Actor string `json:"actor"`
ID string `json:"id"`
@@ -515,7 +511,7 @@ func (suite *FromFederatorTestSuite) TestProcessFollowRequestUnlocked() {
To string `json:"to"`
Type string `json:"type"`
}{}
- err = json.Unmarshal(acceptBytes, accept)
+ err = json.Unmarshal(sent[0], accept)
suite.NoError(err)
suite.Equal(targetAccount.URI, accept.Actor)
@@ -526,6 +522,23 @@ func (suite *FromFederatorTestSuite) TestProcessFollowRequestUnlocked() {
suite.Equal("Follow", accept.Object.Type)
suite.Equal(originAccount.URI, accept.To)
suite.Equal("Accept", accept.Type)
+
+ // a notification should be streamed
+ var msg *stream.Message
+ select {
+ case msg = <-wssStream.Messages:
+ // fine
+ case <-time.After(5 * time.Second):
+ suite.FailNow("no message from wssStream")
+ }
+ suite.Equal(stream.EventTypeNotification, msg.Event)
+ suite.NotEmpty(msg.Payload)
+ suite.EqualValues([]string{stream.TimelineHome}, msg.Stream)
+ notif := &model.Notification{}
+ err = json.Unmarshal([]byte(msg.Payload), notif)
+ suite.NoError(err)
+ suite.Equal("follow", notif.Type)
+ suite.Equal(originAccount.ID, notif.Account.ID)
}
// TestCreateStatusFromIRI checks if a forwarded status can be dereferenced by the processor.