Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Aug 21, 2024
1 parent f088e1d commit a9a8727
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion test/unfollow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ func TestUnfollow_HappyFlow(t *testing.T) {

assert.NoError((inbox.FeedUpdater{Domain: domain, Config: server.cfg, DB: server.db}).Run(context.Background()))

users = server.Handle("/users", server.Alice)
assert.Contains(users, "Hello followers")
}

func TestUnfollow_HappyFlowBeforeFeedUpdate(t *testing.T) {
server := newTestServer()
defer server.Shutdown()

assert := assert.New(t)

follow := server.Handle("/users/follow/"+strings.TrimPrefix(server.Bob.ID, "https://"), server.Alice)
assert.Equal(fmt.Sprintf("30 /users/outbox/%s\r\n", strings.TrimPrefix(server.Bob.ID, "https://")), follow)

say := server.Handle("/users/whisper?Hello%20followers", server.Bob)
assert.Regexp(`^30 /users/view/\S+\r\n$`, say)

users := server.Handle("/users", server.Alice)
assert.NotContains(users, "Hello followers")

unfollow := server.Handle("/users/unfollow/"+strings.TrimPrefix(server.Bob.ID, "https://"), server.Alice)
assert.Equal(fmt.Sprintf("30 /users/outbox/%s\r\n", strings.TrimPrefix(server.Bob.ID, "https://")), unfollow)

assert.NoError((inbox.FeedUpdater{Domain: domain, Config: server.cfg, DB: server.db}).Run(context.Background()))

users = server.Handle("/users", server.Alice)
assert.NotContains(users, "Hello followers")
}
Expand Down Expand Up @@ -74,7 +98,7 @@ func TestUnfollow_FollowAgain(t *testing.T) {
assert.NoError((inbox.FeedUpdater{Domain: domain, Config: server.cfg, DB: server.db}).Run(context.Background()))

users = server.Handle("/users", server.Alice)
assert.NotContains(users, "Hello followers")
assert.Contains(users, "Hello followers")

follow = server.Handle("/users/follow/"+strings.TrimPrefix(server.Bob.ID, "https://"), server.Alice)
assert.Equal(fmt.Sprintf("30 /users/outbox/%s\r\n", strings.TrimPrefix(server.Bob.ID, "https://")), follow)
Expand Down

0 comments on commit a9a8727

Please sign in to comment.