go-fed / activity

ActivityStreams & ActivityPub in golang, oh my!
BSD 3-Clause "New" or "Revised" License
702 stars 111 forks source link

Broken tests are causing GitHub Actions to fail #157

Open SudoVim opened 2 years ago

SudoVim commented 2 years ago

I haven't started using this library yet, but I noticed that the tests are broken. Specifically, there's a missing Host header here:

--- FAIL: TestHttpSigTransportDereference (0.00s)
    --- FAIL: TestHttpSigTransportDereference/Dereferences (0.00s)
        transport.go:124: Unexpected call to *pub.MockSigner.SignRequest([[115 111 109 101 32 112 114 105 118 97 116 101 32 107 101 121] myPubKeyId 0xc000166b00 []]) at /home/michael/projects/activity/pub/mock_httpsig_test.go:41 because: 
            Expected call at /home/michael/projects/activity/pub/transport_test.go:74 doesn't match the argument at index 2.
            Got: &{GET https://example.com/note/1 HTTP/1.1 1 1 map[Accept:[application/ld+json; profile="https://www.w3.org/ns/activitystreams"] Accept-Charset:[utf-8] Date:[Thu, 03 Feb 2000 09:05:06 GMT] Host:[example.com] User-Agent:[testApp (go-fed/activity v1.0.0)]] <nil> <nil> 0 [] false example.com map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000240b8}
            Want: is equal to &{GET https://example.com/note/1 HTTP/1.1 1 1 map[Accept:[application/ld+json; profile="https://www.w3.org/ns/activitystreams"] Accept-Charset:[utf-8] Date:[Thu, 03 Feb 2000 09:05:06 GMT] User-Agent:[testApp (go-fed/activity v1.0.0)]] <nil> <nil> 0 [] false example.com map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc0000240b8}

And these tests are missing an additional Lock, InboxForActor, Unlock for each recipient:

    --- FAIL: TestDeliver/ReturnsErrorIfBatchDeliverFails (0.00s)
        side_effect_actor.go:687: Unexpected call to *pub.MockDatabase.Lock([context.Background https://other.example.com/dakota]) at /home/michael/projects/activity/pub/mock_database_test.go:235 because: 
            Expected call at /home/michael/projects/activity/pub/side_effect_actor_test.go:1637 doesn't match the argument at index 1.
            Got: https://other.example.com/dakota
            Want: is equal to https://example.com/addison/outbox
            Expected call at /home/michael/projects/activity/pub/side_effect_actor_test.go:1641 doesn't match the argument at index 1.
            Got: https://other.example.com/dakota
            Want: is equal to https://maybe.example.com/person

I've actually already fixed these broken tests, but in the process of submitting a PR, I noticed that you require an issue be submitted first, so here's my issue. I'll submit a follow-up PR with my fix.