From a9a8727f9511a69786a5816c4965125d90f8e89a Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Wed, 21 Aug 2024 21:31:07 +0300 Subject: [PATCH] cleanup --- test/unfollow_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/test/unfollow_test.go b/test/unfollow_test.go index 5c0e48bd..b8d89c25 100644 --- a/test/unfollow_test.go +++ b/test/unfollow_test.go @@ -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") } @@ -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)