bundb_test.go (3302B)
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 bundb_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 BunDBStandardTestSuite 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 testEmojis map[string]*gtsmodel.Emoji 47 testReports map[string]*gtsmodel.Report 48 testBookmarks map[string]*gtsmodel.StatusBookmark 49 testFaves map[string]*gtsmodel.StatusFave 50 testLists map[string]*gtsmodel.List 51 testListEntries map[string]*gtsmodel.ListEntry 52 } 53 54 func (suite *BunDBStandardTestSuite) SetupSuite() { 55 suite.testTokens = testrig.NewTestTokens() 56 suite.testClients = testrig.NewTestClients() 57 suite.testApplications = testrig.NewTestApplications() 58 suite.testUsers = testrig.NewTestUsers() 59 suite.testAccounts = testrig.NewTestAccounts() 60 suite.testAttachments = testrig.NewTestAttachments() 61 suite.testStatuses = testrig.NewTestStatuses() 62 suite.testTags = testrig.NewTestTags() 63 suite.testMentions = testrig.NewTestMentions() 64 suite.testFollows = testrig.NewTestFollows() 65 suite.testEmojis = testrig.NewTestEmojis() 66 suite.testReports = testrig.NewTestReports() 67 suite.testBookmarks = testrig.NewTestBookmarks() 68 suite.testFaves = testrig.NewTestFaves() 69 suite.testLists = testrig.NewTestLists() 70 suite.testListEntries = testrig.NewTestListEntries() 71 } 72 73 func (suite *BunDBStandardTestSuite) SetupTest() { 74 testrig.InitTestConfig() 75 testrig.InitTestLog() 76 suite.state.Caches.Init() 77 suite.db = testrig.NewTestDB(&suite.state) 78 testrig.StartTimelines(&suite.state, visibility.NewFilter(&suite.state), testrig.NewTestTypeConverter(suite.db)) 79 testrig.StandardDBSetup(suite.db, suite.testAccounts) 80 } 81 82 func (suite *BunDBStandardTestSuite) TearDownTest() { 83 testrig.StandardDBTeardown(suite.db) 84 }