boostable_test.go (4831B)
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 visibility_test 19 20 import ( 21 "context" 22 "testing" 23 24 "github.com/stretchr/testify/suite" 25 ) 26 27 type StatusBoostableTestSuite struct { 28 FilterStandardTestSuite 29 } 30 31 func (suite *StatusBoostableTestSuite) TestOwnPublicBoostable() { 32 testStatus := suite.testStatuses["local_account_1_status_1"] 33 testAccount := suite.testAccounts["local_account_1"] 34 ctx := context.Background() 35 36 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 37 suite.NoError(err) 38 39 suite.True(boostable) 40 } 41 42 func (suite *StatusBoostableTestSuite) TestOwnUnlockedBoostable() { 43 testStatus := suite.testStatuses["local_account_1_status_2"] 44 testAccount := suite.testAccounts["local_account_1"] 45 ctx := context.Background() 46 47 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 48 suite.NoError(err) 49 50 suite.True(boostable) 51 } 52 53 func (suite *StatusBoostableTestSuite) TestOwnMutualsOnlyNonInteractiveBoostable() { 54 testStatus := suite.testStatuses["local_account_1_status_3"] 55 testAccount := suite.testAccounts["local_account_1"] 56 ctx := context.Background() 57 58 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 59 suite.NoError(err) 60 61 suite.True(boostable) 62 } 63 64 func (suite *StatusBoostableTestSuite) TestOwnMutualsOnlyBoostable() { 65 testStatus := suite.testStatuses["local_account_1_status_4"] 66 testAccount := suite.testAccounts["local_account_1"] 67 ctx := context.Background() 68 69 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 70 suite.NoError(err) 71 72 suite.True(boostable) 73 } 74 75 func (suite *StatusBoostableTestSuite) TestOwnFollowersOnlyBoostable() { 76 testStatus := suite.testStatuses["local_account_1_status_5"] 77 testAccount := suite.testAccounts["local_account_1"] 78 ctx := context.Background() 79 80 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 81 suite.NoError(err) 82 83 suite.True(boostable) 84 } 85 86 func (suite *StatusBoostableTestSuite) TestOwnDirectNotBoostable() { 87 testStatus := suite.testStatuses["local_account_2_status_6"] 88 testAccount := suite.testAccounts["local_account_2"] 89 ctx := context.Background() 90 91 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 92 suite.NoError(err) 93 94 suite.False(boostable) 95 } 96 97 func (suite *StatusBoostableTestSuite) TestOtherPublicBoostable() { 98 testStatus := suite.testStatuses["local_account_2_status_1"] 99 testAccount := suite.testAccounts["local_account_1"] 100 ctx := context.Background() 101 102 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 103 suite.NoError(err) 104 105 suite.True(boostable) 106 } 107 108 func (suite *StatusBoostableTestSuite) TestOtherUnlistedBoostable() { 109 testStatus := suite.testStatuses["local_account_1_status_2"] 110 testAccount := suite.testAccounts["local_account_2"] 111 ctx := context.Background() 112 113 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 114 suite.NoError(err) 115 116 suite.True(boostable) 117 } 118 119 func (suite *StatusBoostableTestSuite) TestOtherFollowersOnlyNotBoostable() { 120 testStatus := suite.testStatuses["local_account_2_status_7"] 121 testAccount := suite.testAccounts["local_account_1"] 122 ctx := context.Background() 123 124 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 125 suite.NoError(err) 126 127 suite.False(boostable) 128 } 129 130 func (suite *StatusBoostableTestSuite) TestOtherDirectNotBoostable() { 131 testStatus := suite.testStatuses["local_account_2_status_6"] 132 testAccount := suite.testAccounts["local_account_1"] 133 ctx := context.Background() 134 135 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 136 suite.NoError(err) 137 138 suite.False(boostable) 139 } 140 141 func (suite *StatusBoostableTestSuite) TestRemoteFollowersOnlyNotVisible() { 142 testStatus := suite.testStatuses["local_account_1_status_5"] 143 testAccount := suite.testAccounts["remote_account_1"] 144 ctx := context.Background() 145 146 boostable, err := suite.filter.StatusBoostable(ctx, testAccount, testStatus) 147 suite.NoError(err) 148 149 suite.False(boostable) 150 } 151 152 func TestStatusBoostableTestSuite(t *testing.T) { 153 suite.Run(t, new(StatusBoostableTestSuite)) 154 }