Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken tests #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions pub/side_effect_actor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1162,6 +1173,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1200,6 +1222,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1239,6 +1272,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1277,6 +1321,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1316,6 +1371,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1355,6 +1421,9 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)
mockDb.EXPECT().Lock(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1394,6 +1463,9 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI4)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)
mockDb.EXPECT().Lock(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1425,6 +1497,9 @@ func TestDeliver(t *testing.T) {
mockFp.EXPECT().MaxDeliveryRecursionDepth(ctx).Return(1)
mockTp.EXPECT().Dereference(ctx, mustParse(testAudienceIRI)).Return(
mustSerializeToBytes(testCollectionOfActors), nil)
mockDb.EXPECT().Lock(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testAudienceIRI))
mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1478,6 +1553,47 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil).Times(4)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil).Times(4)

// Inbox for first to
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second to
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

// Inbox for first bto
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second bto
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

// Inbox for first cc
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second cc
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

// Inbox for first bcc
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second bcc
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1518,6 +1634,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1554,6 +1681,17 @@ func TestDeliver(t *testing.T) {
c.EXPECT().NewTransport(ctx, mustParse(testMyOutboxIRI), goFedUserAgent()).Return(
mockTp, nil)
mockFp.EXPECT().MaxDeliveryRecursionDepth(ctx).Return(1)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI)).Return(
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
Expand Down Expand Up @@ -1595,6 +1733,17 @@ func TestDeliver(t *testing.T) {
[]byte{}, fmt.Errorf("test error"))
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down Expand Up @@ -1634,6 +1783,17 @@ func TestDeliver(t *testing.T) {
mustSerializeToBytes(testFederatedPerson1), nil)
mockTp.EXPECT().Dereference(ctx, mustParse(testFederatedActorIRI2)).Return(
mustSerializeToBytes(testFederatedPerson2), nil)

// Inbox for first recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI))

// Inbox for second recipient
mockDb.EXPECT().Lock(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().InboxForActor(ctx, mustParse(testFederatedActorIRI2))
mockDb.EXPECT().Unlock(ctx, mustParse(testFederatedActorIRI2))

mockDb.EXPECT().Lock(ctx, mustParse(testMyOutboxIRI))
mockDb.EXPECT().ActorForOutbox(ctx, mustParse(testMyOutboxIRI)).Return(
mustParse(testPersonIRI), nil)
Expand Down
1 change: 1 addition & 0 deletions pub/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestHttpSigTransportDereference(t *testing.T) {
expectReq.Header.Add(acceptHeader, acceptHeaderValue)
expectReq.Header.Add("Accept-Charset", "utf-8")
expectReq.Header.Add("Date", nowDateHeader())
expectReq.Header.Add("Host", "example.com")
expectReq.Header.Add("User-Agent", fmt.Sprintf("%s %s", testAppAgent, goFedUserAgent()))
respR := httptest.NewRecorder()
respR.Write(testRespBody)
Expand Down