summaryrefslogtreecommitdiff
path: root/internal/db/bundb/account_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/bundb/account_test.go')
-rw-r--r--internal/db/bundb/account_test.go41
1 files changed, 37 insertions, 4 deletions
diff --git a/internal/db/bundb/account_test.go b/internal/db/bundb/account_test.go
index 13bdba20d..a510e2152 100644
--- a/internal/db/bundb/account_test.go
+++ b/internal/db/bundb/account_test.go
@@ -28,6 +28,7 @@ import (
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap"
+ "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/db/bundb"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/uptrace/bun"
@@ -38,25 +39,25 @@ type AccountTestSuite struct {
}
func (suite *AccountTestSuite) TestGetAccountStatuses() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", false, false, false)
+ statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", false, false)
suite.NoError(err)
suite.Len(statuses, 5)
}
func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesAndReblogs() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, false, false)
+ statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, false)
suite.NoError(err)
suite.Len(statuses, 5)
}
func (suite *AccountTestSuite) TestGetAccountStatusesExcludeRepliesAndReblogsPublicOnly() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, false, true)
+ statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, true, true, "", "", false, true)
suite.NoError(err)
suite.Len(statuses, 1)
}
func (suite *AccountTestSuite) TestGetAccountStatusesMediaOnly() {
- statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", false, true, false)
+ statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 20, false, false, "", "", true, false)
suite.NoError(err)
suite.Len(statuses, 1)
}
@@ -214,6 +215,38 @@ func (suite *AccountTestSuite) TestGettingBookmarksWithNoAccount() {
suite.Nil(statuses)
}
+func (suite *AccountTestSuite) TestGetAccountPinnedStatusesSomeResults() {
+ testAccount := suite.testAccounts["admin_account"]
+
+ statuses, err := suite.db.GetAccountPinnedStatuses(context.Background(), testAccount.ID)
+ suite.NoError(err)
+ suite.Len(statuses, 2) // This account has 2 statuses pinned.
+}
+
+func (suite *AccountTestSuite) TestGetAccountPinnedStatusesNothingPinned() {
+ testAccount := suite.testAccounts["local_account_1"]
+
+ statuses, err := suite.db.GetAccountPinnedStatuses(context.Background(), testAccount.ID)
+ suite.ErrorIs(err, db.ErrNoEntries)
+ suite.Empty(statuses) // This account has nothing pinned.
+}
+
+func (suite *AccountTestSuite) TestCountAccountPinnedSomeResults() {
+ testAccount := suite.testAccounts["admin_account"]
+
+ pinned, err := suite.db.CountAccountPinned(context.Background(), testAccount.ID)
+ suite.NoError(err)
+ suite.Equal(pinned, 2) // This account has 2 statuses pinned.
+}
+
+func (suite *AccountTestSuite) TestCountAccountPinnedNothingPinned() {
+ testAccount := suite.testAccounts["local_account_1"]
+
+ pinned, err := suite.db.CountAccountPinned(context.Background(), testAccount.ID)
+ suite.NoError(err)
+ suite.Equal(pinned, 0) // This account has nothing pinned.
+}
+
func TestAccountTestSuite(t *testing.T) {
suite.Run(t, new(AccountTestSuite))
}