summaryrefslogtreecommitdiff
path: root/internal/db/bundb/account_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-05-22 16:32:36 +0200
committerLibravatar GitHub <noreply@github.com>2023-05-22 16:32:36 +0200
commitc48abd8bc0e708fedcddd7985c00243580464452 (patch)
tree6f9eb8b0537c75c3d68f1a9e0135870e6e0e7575 /internal/db/bundb/account_test.go
parent[chore]: Bump github.com/go-playground/validator/v10 (#1812) (diff)
downloadgotosocial-c48abd8bc0e708fedcddd7985c00243580464452.tar.xz
[chore] update account statuses paging logic (#1814)
Diffstat (limited to 'internal/db/bundb/account_test.go')
-rw-r--r--internal/db/bundb/account_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/db/bundb/account_test.go b/internal/db/bundb/account_test.go
index 2241ab783..bfe6df536 100644
--- a/internal/db/bundb/account_test.go
+++ b/internal/db/bundb/account_test.go
@@ -45,6 +45,34 @@ func (suite *AccountTestSuite) TestGetAccountStatuses() {
suite.Len(statuses, 5)
}
+func (suite *AccountTestSuite) TestGetAccountStatusesPageDown() {
+ // get the first page
+ statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 2, false, false, "", "", false, false)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+ suite.Len(statuses, 2)
+
+ // get the second page
+ statuses, err = suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 2, false, false, statuses[len(statuses)-1].ID, "", false, false)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+ suite.Len(statuses, 2)
+
+ // get the third page
+ statuses, err = suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 2, false, false, statuses[len(statuses)-1].ID, "", false, false)
+ if err != nil {
+ suite.FailNow(err.Error())
+ }
+ suite.Len(statuses, 1)
+
+ // try to get the last page (should be empty)
+ statuses, err = suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 2, false, false, statuses[len(statuses)-1].ID, "", false, false)
+ suite.ErrorIs(err, db.ErrNoEntries)
+ suite.Empty(statuses)
+}
+
func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesAndReblogs() {
statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, false)
suite.NoError(err)