// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
package account_test
import (
"context"
"testing"
"github.com/stretchr/testify/suite"
)
type GetRSSTestSuite struct {
AccountStandardTestSuite
}
func (suite *GetRSSTestSuite) TestGetAccountRSSAdmin() {
getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(context.Background(), "admin")
suite.NoError(err)
suite.EqualValues(1634726497, lastModified.Unix())
feed, err := getFeed()
suite.NoError(err)
suite.Equal(`Posts from @admin@localhost:8080
http://localhost:8080/@admin
Posts from @admin@localhost:8080Wed, 20 Oct 2021 10:41:37 +0000Wed, 20 Oct 2021 10:41:37 +0000open to see some puppies
http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37
@admin@localhost:8080 made a new post: "🐕🐕🐕🐕🐕"@admin@localhost:8080http://localhost:8080/@admin/statuses/01F8MHAAY43M6RJ473VQFCVH37Wed, 20 Oct 2021 12:36:45 +0000hello world! #welcome ! first post on the instance :rainbow: !
http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0R
@admin@localhost:8080 posted 1 attachment: "hello world! #welcome ! first post on the instance :rainbow: !" !]]>@admin@localhost:8080http://localhost:8080/@admin/statuses/01F8MH75CBF9JFX4ZAD54N0W0RWed, 20 Oct 2021 11:36:45 +0000`, feed)
}
func (suite *GetRSSTestSuite) TestGetAccountRSSZork() {
getFeed, lastModified, err := suite.accountProcessor.GetRSSFeedForUsername(context.Background(), "the_mighty_zork")
suite.NoError(err)
suite.EqualValues(1704878640, lastModified.Unix())
feed, err := getFeed()
suite.NoError(err)
suite.Equal(`Posts from @the_mighty_zork@localhost:8080
http://localhost:8080/@the_mighty_zork
Posts from @the_mighty_zork@localhost:8080Wed, 10 Jan 2024 09:24:00 +0000Wed, 10 Jan 2024 09:24:00 +0000http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webpAvatar for @the_mighty_zork@localhost:8080
http://localhost:8080/@the_mighty_zork
HTML in post
http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40
@the_mighty_zork@localhost:8080 made a new post: "Here's a bunch of HTML, read it and weep, weep then!
`+"```"+`html
<section class="about-user">
<div class="col-header">
<h2>About</h2>
</div>
<div class="fields">
<h3 class="sr-only">Fields</h3>
<dl>
...Here's a bunch of HTML, read it and weep, weep then!
<section class="about-user">
<div class="col-header">
<h2>About</h2>
</div>
<div class="fields">
<h3 class="sr-only">Fields</h3>
<dl>
<div class="field">
<dt>should you follow me?</dt>
<dd>maybe!</dd>
</div>
<div class="field">
<dt>age</dt>
<dd>120</dd>
</div>
</dl>
</div>
<div class="bio">
<h3 class="sr-only">Bio</h3>
<p>i post about things that concern me</p>
</div>
<div class="sr-only" role="group">
<h3 class="sr-only">Stats</h3>
<span>Joined in Jun, 2022.</span>
<span>8 posts.</span>
<span>Followed by 1.</span>
<span>Following 1.</span>
</div>
<div class="accountstats" aria-hidden="true">
<b>Joined</b><time datetime="2022-06-04T13:12:00.000Z">Jun, 2022</time>
<b>Posts</b><span>8</span>
<b>Followed by</b><span>1</span>
<b>Following</b><span>1</span>
</div>
</section>
There, hope you liked that!
]]>
@the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01HH9KYNQPA416TNJ53NSATP40Sun, 10 Dec 2023 09:24:00 +0000introduction post
http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMY
@the_mighty_zork@localhost:8080 made a new post: "hello everyone!"@the_mighty_zork@localhost:8080http://localhost:8080/@the_mighty_zork/statuses/01F8MHAMCHF6Y650WCRSCP4WMYWed, 20 Oct 2021 10:40:37 +0000
`, 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)
suite.Equal(`Posts from @the_mighty_zork@localhost:8080
http://localhost:8080/@the_mighty_zork
Posts from @the_mighty_zork@localhost:8080Fri, 20 May 2022 11:09:18 +0000Fri, 20 May 2022 11:09:18 +0000http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webpAvatar for @the_mighty_zork@localhost:8080
http://localhost:8080/@the_mighty_zork
`, feed)
}
func TestGetRSSTestSuite(t *testing.T) {
suite.Run(t, new(GetRSSTestSuite))
}