diff options
author | 2023-02-25 13:16:30 +0100 | |
---|---|---|
committer | 2023-02-25 12:16:30 +0000 | |
commit | c27b4d7ed02cdabac00c3ddedb8201b74f745ec6 (patch) | |
tree | d80f621241fd67a4e5de2d21a8c24776552175f5 /internal/db/bundb/account_test.go | |
parent | [chore] Update gin to v1.9.0 (#1553) (diff) | |
download | gotosocial-c27b4d7ed02cdabac00c3ddedb8201b74f745ec6.tar.xz |
[feature] Client API endpoints + v. basic web view for pinned posts (#1547)
* implement status pin client api + web handler
* make test names + comments more descriptive
* don't use separate table for status pins
* remove unused add + remove checking
* tidy up + add some more tests
Diffstat (limited to 'internal/db/bundb/account_test.go')
-rw-r--r-- | internal/db/bundb/account_test.go | 41 |
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)) } |