gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

bookmark_test.go (2163B)


      1 // GoToSocial
      2 // Copyright (C) GoToSocial Authors admin@gotosocial.org
      3 // SPDX-License-Identifier: AGPL-3.0-or-later
      4 //
      5 // This program is free software: you can redistribute it and/or modify
      6 // it under the terms of the GNU Affero General Public License as published by
      7 // the Free Software Foundation, either version 3 of the License, or
      8 // (at your option) any later version.
      9 //
     10 // This program is distributed in the hope that it will be useful,
     11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 // GNU Affero General Public License for more details.
     14 //
     15 // You should have received a copy of the GNU Affero General Public License
     16 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 package status_test
     19 
     20 import (
     21 	"context"
     22 	"testing"
     23 
     24 	"github.com/stretchr/testify/suite"
     25 )
     26 
     27 type StatusBookmarkTestSuite struct {
     28 	StatusStandardTestSuite
     29 }
     30 
     31 func (suite *StatusBookmarkTestSuite) TestBookmark() {
     32 	ctx := context.Background()
     33 
     34 	// bookmark a status
     35 	bookmarkingAccount1 := suite.testAccounts["local_account_1"]
     36 	targetStatus1 := suite.testStatuses["admin_account_status_1"]
     37 
     38 	bookmark1, err := suite.status.BookmarkCreate(ctx, bookmarkingAccount1, targetStatus1.ID)
     39 	suite.NoError(err)
     40 	suite.NotNil(bookmark1)
     41 	suite.True(bookmark1.Bookmarked)
     42 	suite.Equal(targetStatus1.ID, bookmark1.ID)
     43 }
     44 
     45 func (suite *StatusBookmarkTestSuite) TestUnbookmark() {
     46 	ctx := context.Background()
     47 
     48 	// bookmark a status
     49 	bookmarkingAccount1 := suite.testAccounts["local_account_1"]
     50 	targetStatus1 := suite.testStatuses["admin_account_status_1"]
     51 
     52 	bookmark1, err := suite.status.BookmarkCreate(ctx, bookmarkingAccount1, targetStatus1.ID)
     53 	suite.NoError(err)
     54 	suite.NotNil(bookmark1)
     55 	suite.True(bookmark1.Bookmarked)
     56 	suite.Equal(targetStatus1.ID, bookmark1.ID)
     57 
     58 	bookmark2, err := suite.status.BookmarkRemove(ctx, bookmarkingAccount1, targetStatus1.ID)
     59 	suite.NoError(err)
     60 	suite.NotNil(bookmark2)
     61 	suite.False(bookmark2.Bookmarked)
     62 	suite.Equal(targetStatus1.ID, bookmark1.ID)
     63 }
     64 
     65 func TestStatusBookmarkTestSuite(t *testing.T) {
     66 	suite.Run(t, new(StatusBookmarkTestSuite))
     67 }