favourites_test.go (4191B)
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 favourites_test 19 20 import ( 21 "github.com/stretchr/testify/suite" 22 "github.com/superseriousbusiness/gotosocial/internal/api/client/favourites" 23 "github.com/superseriousbusiness/gotosocial/internal/db" 24 "github.com/superseriousbusiness/gotosocial/internal/email" 25 "github.com/superseriousbusiness/gotosocial/internal/federation" 26 "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" 27 "github.com/superseriousbusiness/gotosocial/internal/media" 28 "github.com/superseriousbusiness/gotosocial/internal/processing" 29 "github.com/superseriousbusiness/gotosocial/internal/state" 30 "github.com/superseriousbusiness/gotosocial/internal/storage" 31 "github.com/superseriousbusiness/gotosocial/internal/typeutils" 32 "github.com/superseriousbusiness/gotosocial/internal/visibility" 33 "github.com/superseriousbusiness/gotosocial/testrig" 34 ) 35 36 type FavouritesStandardTestSuite struct { 37 // standard suite interfaces 38 suite.Suite 39 db db.DB 40 tc typeutils.TypeConverter 41 mediaManager *media.Manager 42 federator federation.Federator 43 emailSender email.Sender 44 processor *processing.Processor 45 storage *storage.Driver 46 state state.State 47 48 // standard suite models 49 testTokens map[string]*gtsmodel.Token 50 testClients map[string]*gtsmodel.Client 51 testApplications map[string]*gtsmodel.Application 52 testUsers map[string]*gtsmodel.User 53 testAccounts map[string]*gtsmodel.Account 54 testAttachments map[string]*gtsmodel.MediaAttachment 55 testStatuses map[string]*gtsmodel.Status 56 testFollows map[string]*gtsmodel.Follow 57 58 // module being tested 59 favModule *favourites.Module 60 } 61 62 func (suite *FavouritesStandardTestSuite) SetupSuite() { 63 suite.testTokens = testrig.NewTestTokens() 64 suite.testClients = testrig.NewTestClients() 65 suite.testApplications = testrig.NewTestApplications() 66 suite.testUsers = testrig.NewTestUsers() 67 suite.testAccounts = testrig.NewTestAccounts() 68 suite.testAttachments = testrig.NewTestAttachments() 69 suite.testStatuses = testrig.NewTestStatuses() 70 suite.testFollows = testrig.NewTestFollows() 71 } 72 73 func (suite *FavouritesStandardTestSuite) SetupTest() { 74 suite.state.Caches.Init() 75 testrig.StartWorkers(&suite.state) 76 77 testrig.InitTestConfig() 78 testrig.InitTestLog() 79 80 suite.db = testrig.NewTestDB(&suite.state) 81 suite.state.DB = suite.db 82 suite.storage = testrig.NewInMemoryStorage() 83 suite.state.Storage = suite.storage 84 85 suite.tc = testrig.NewTestTypeConverter(suite.db) 86 87 testrig.StartTimelines( 88 &suite.state, 89 visibility.NewFilter(&suite.state), 90 suite.tc, 91 ) 92 93 testrig.StandardDBSetup(suite.db, nil) 94 testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") 95 96 suite.mediaManager = testrig.NewTestMediaManager(&suite.state) 97 suite.federator = testrig.NewTestFederator(&suite.state, testrig.NewTestTransportController(&suite.state, testrig.NewMockHTTPClient(nil, "../../../../testrig/media")), suite.mediaManager) 98 suite.emailSender = testrig.NewEmailSender("../../../../web/template/", nil) 99 suite.processor = testrig.NewTestProcessor(&suite.state, suite.federator, suite.emailSender, suite.mediaManager) 100 suite.favModule = favourites.New(suite.processor) 101 } 102 103 func (suite *FavouritesStandardTestSuite) TearDownTest() { 104 testrig.StandardDBTeardown(suite.db) 105 testrig.StandardStorageTeardown(suite.storage) 106 testrig.StopWorkers(&suite.state) 107 } 108 109 func (suite *FavouritesStandardTestSuite) TestProcessFave() {}