filter_test.go (2698B)
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 "github.com/stretchr/testify/suite" 22 "github.com/superseriousbusiness/gotosocial/internal/db" 23 "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" 24 "github.com/superseriousbusiness/gotosocial/internal/state" 25 "github.com/superseriousbusiness/gotosocial/internal/visibility" 26 "github.com/superseriousbusiness/gotosocial/testrig" 27 ) 28 29 type FilterStandardTestSuite struct { 30 // standard suite interfaces 31 suite.Suite 32 db db.DB 33 state state.State 34 35 // standard suite models 36 testTokens map[string]*gtsmodel.Token 37 testClients map[string]*gtsmodel.Client 38 testApplications map[string]*gtsmodel.Application 39 testUsers map[string]*gtsmodel.User 40 testAccounts map[string]*gtsmodel.Account 41 testAttachments map[string]*gtsmodel.MediaAttachment 42 testStatuses map[string]*gtsmodel.Status 43 testTags map[string]*gtsmodel.Tag 44 testMentions map[string]*gtsmodel.Mention 45 testFollows map[string]*gtsmodel.Follow 46 47 filter *visibility.Filter 48 } 49 50 func (suite *FilterStandardTestSuite) SetupSuite() { 51 suite.testTokens = testrig.NewTestTokens() 52 suite.testClients = testrig.NewTestClients() 53 suite.testApplications = testrig.NewTestApplications() 54 suite.testUsers = testrig.NewTestUsers() 55 suite.testAccounts = testrig.NewTestAccounts() 56 suite.testAttachments = testrig.NewTestAttachments() 57 suite.testStatuses = testrig.NewTestStatuses() 58 suite.testTags = testrig.NewTestTags() 59 suite.testMentions = testrig.NewTestMentions() 60 suite.testFollows = testrig.NewTestFollows() 61 } 62 63 func (suite *FilterStandardTestSuite) SetupTest() { 64 suite.state.Caches.Init() 65 66 testrig.InitTestConfig() 67 testrig.InitTestLog() 68 69 suite.db = testrig.NewTestDB(&suite.state) 70 suite.filter = visibility.NewFilter(&suite.state) 71 72 testrig.StandardDBSetup(suite.db, nil) 73 } 74 75 func (suite *FilterStandardTestSuite) TearDownTest() { 76 testrig.StandardDBTeardown(suite.db) 77 }