diff options
author | 2023-07-10 17:05:59 +0200 | |
---|---|---|
committer | 2023-07-10 17:05:59 +0200 | |
commit | ca5492b65f45c7db8a9cfb767b0b48aa6cf6fe24 (patch) | |
tree | 0dc008100b8f6956e7bfb4c71935dfad532dc745 /internal/processing/account/rss_test.go | |
parent | [chore]: Bump golang.org/x/oauth2 from 0.9.0 to 0.10.0 (#1975) (diff) | |
download | gotosocial-ca5492b65f45c7db8a9cfb767b0b48aa6cf6fe24.tar.xz |
[bugfix] Tidy up rss feed serving; don't error on empty feed (#1970)
* [bugfix] Tidy up rss feed serving; don't error on empty feed
* fall back to account creation time as rss feed update time
* return feed early when account has no eligible statuses
Diffstat (limited to 'internal/processing/account/rss_test.go')
-rw-r--r-- | internal/processing/account/rss_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/processing/account/rss_test.go b/internal/processing/account/rss_test.go index 1a0bb9788..80f86211f 100644 --- a/internal/processing/account/rss_test.go +++ b/internal/processing/account/rss_test.go @@ -55,6 +55,34 @@ func (suite *GetRSSTestSuite) TestGetAccountRSSZork() { suite.Equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n <channel>\n <title>Posts from @the_mighty_zork@localhost:8080</title>\n <link>http://localhost:8080/@the_mighty_zork</link>\n <description>Posts from @the_mighty_zork@localhost:8080</description>\n <pubDate>Wed, 20 Oct 2021 10:40:37 +0000</pubDate>\n <lastBuildDate>Wed, 20 Oct 2021 10:40:37 +0000</lastBuildDate>\n <image>\n <url>http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.jpg</url>\n <title>Avatar for @the_mighty_zork@localhost:8080</title>\n <link>http://localhost:8080/@the_mighty_zork</link>\n </image>\n <item>\n <title>introduction post</title>\n <link>http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY</link>\n <description>@the_mighty_zork@localhost:8080 made a new post: "hello everyone!"</description>\n <content:encoded><![CDATA[hello everyone!]]></content:encoded>\n <author>@the_mighty_zork@localhost:8080</author>\n <guid>http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY</guid>\n <pubDate>Wed, 20 Oct 2021 10:40:37 +0000</pubDate>\n <source>http://localhost:8080/@the_mighty_zork/feed.rss</source>\n </item>\n </channel>\n</rss>", feed) } +func (suite *GetRSSTestSuite) TestGetAccountRSSZorkNoPosts() { + ctx := context.Background() + + // Get all of zork's posts. + statuses, err := suite.db.GetAccountStatuses(ctx, suite.testAccounts["local_account_1"].ID, 0, false, false, "", "", false, false) + if err != nil { + suite.FailNow(err.Error()) + } + + // Now delete them! Hahaha! + for _, status := range statuses { + if err := suite.db.DeleteStatusByID(ctx, status.ID); err != nil { + suite.FailNow(err.Error()) + } + } + + getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(ctx, "the_mighty_zork") + suite.NoError(err) + suite.Empty(lastModified) + + feed, err := getFeed() + suite.NoError(err) + + fmt.Println(feed) + + suite.Equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?><rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n <channel>\n <title>Posts from @the_mighty_zork@localhost:8080</title>\n <link>http://localhost:8080/@the_mighty_zork</link>\n <description>Posts from @the_mighty_zork@localhost:8080</description>\n <pubDate>Fri, 20 May 2022 11:09:18 +0000</pubDate>\n <lastBuildDate>Fri, 20 May 2022 11:09:18 +0000</lastBuildDate>\n <image>\n <url>http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.jpg</url>\n <title>Avatar for @the_mighty_zork@localhost:8080</title>\n <link>http://localhost:8080/@the_mighty_zork</link>\n </image>\n </channel>\n</rss>", feed) +} + func TestGetRSSTestSuite(t *testing.T) { suite.Run(t, new(GetRSSTestSuite)) } |