| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | /* | 
					
						
							|  |  |  |    GoToSocial | 
					
						
							| 
									
										
										
										
											2021-12-20 18:42:19 +01:00
										 |  |  |    Copyright (C) 2021-2022 GoToSocial Authors admin@gotosocial.org | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |    This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |    it under the terms of the GNU Affero General Public License as published by | 
					
						
							|  |  |  |    the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |    (at your option) any later version. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |    GNU Affero General Public License for more details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |    along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package account_test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2021-11-13 12:29:08 +01:00
										 |  |  | 	"codeberg.org/gruf/go-store/kv" | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	"github.com/stretchr/testify/suite" | 
					
						
							| 
									
										
										
										
											2021-11-13 17:29:43 +01:00
										 |  |  | 	"github.com/superseriousbusiness/activity/pub" | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/db" | 
					
						
							| 
									
										
										
										
											2021-10-31 15:46:23 +01:00
										 |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/email" | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/federation" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/media" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/messages" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/oauth" | 
					
						
							| 
									
										
										
										
											2022-03-29 11:54:56 +02:00
										 |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/processing" | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/processing/account" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/transport" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/typeutils" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/testrig" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type AccountStandardTestSuite struct { | 
					
						
							|  |  |  | 	// standard suite interfaces | 
					
						
							|  |  |  | 	suite.Suite | 
					
						
							|  |  |  | 	db                  db.DB | 
					
						
							|  |  |  | 	tc                  typeutils.TypeConverter | 
					
						
							| 
									
										
										
										
											2021-09-11 20:12:47 +01:00
										 |  |  | 	storage             *kv.KVStore | 
					
						
							| 
									
										
										
										
											2021-12-28 16:36:00 +01:00
										 |  |  | 	mediaManager        media.Manager | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	oauthServer         oauth.Server | 
					
						
							|  |  |  | 	fromClientAPIChan   chan messages.FromClientAPI | 
					
						
							|  |  |  | 	httpClient          pub.HttpClient | 
					
						
							|  |  |  | 	transportController transport.Controller | 
					
						
							|  |  |  | 	federator           federation.Federator | 
					
						
							| 
									
										
										
										
											2021-10-31 15:46:23 +01:00
										 |  |  | 	emailSender         email.Sender | 
					
						
							|  |  |  | 	sentEmails          map[string]string | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// standard suite models | 
					
						
							|  |  |  | 	testTokens       map[string]*gtsmodel.Token | 
					
						
							|  |  |  | 	testClients      map[string]*gtsmodel.Client | 
					
						
							|  |  |  | 	testApplications map[string]*gtsmodel.Application | 
					
						
							|  |  |  | 	testUsers        map[string]*gtsmodel.User | 
					
						
							|  |  |  | 	testAccounts     map[string]*gtsmodel.Account | 
					
						
							|  |  |  | 	testAttachments  map[string]*gtsmodel.MediaAttachment | 
					
						
							|  |  |  | 	testStatuses     map[string]*gtsmodel.Status | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// module being tested | 
					
						
							|  |  |  | 	accountProcessor account.Processor | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (suite *AccountStandardTestSuite) SetupSuite() { | 
					
						
							|  |  |  | 	suite.testTokens = testrig.NewTestTokens() | 
					
						
							|  |  |  | 	suite.testClients = testrig.NewTestClients() | 
					
						
							|  |  |  | 	suite.testApplications = testrig.NewTestApplications() | 
					
						
							|  |  |  | 	suite.testUsers = testrig.NewTestUsers() | 
					
						
							|  |  |  | 	suite.testAccounts = testrig.NewTestAccounts() | 
					
						
							|  |  |  | 	suite.testAttachments = testrig.NewTestAttachments() | 
					
						
							|  |  |  | 	suite.testStatuses = testrig.NewTestStatuses() | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (suite *AccountStandardTestSuite) SetupTest() { | 
					
						
							| 
									
										
										
										
											2021-10-11 05:37:33 -07:00
										 |  |  | 	testrig.InitTestLog() | 
					
						
							| 
									
										
										
										
											2021-12-07 13:31:39 +01:00
										 |  |  | 	testrig.InitTestConfig() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	suite.db = testrig.NewTestDB() | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	suite.tc = testrig.NewTestTypeConverter(suite.db) | 
					
						
							|  |  |  | 	suite.storage = testrig.NewTestStorage() | 
					
						
							| 
									
										
										
										
											2021-12-28 16:36:00 +01:00
										 |  |  | 	suite.mediaManager = testrig.NewTestMediaManager(suite.db, suite.storage) | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	suite.oauthServer = testrig.NewTestOauthServer(suite.db) | 
					
						
							|  |  |  | 	suite.fromClientAPIChan = make(chan messages.FromClientAPI, 100) | 
					
						
							|  |  |  | 	suite.httpClient = testrig.NewMockHTTPClient(nil) | 
					
						
							|  |  |  | 	suite.transportController = testrig.NewTestTransportController(suite.httpClient, suite.db) | 
					
						
							| 
									
										
										
										
											2022-01-10 18:36:09 +01:00
										 |  |  | 	suite.federator = testrig.NewTestFederator(suite.db, suite.transportController, suite.storage, suite.mediaManager) | 
					
						
							| 
									
										
										
										
											2021-10-31 15:46:23 +01:00
										 |  |  | 	suite.sentEmails = make(map[string]string) | 
					
						
							|  |  |  | 	suite.emailSender = testrig.NewEmailSender("../../../web/template/", suite.sentEmails) | 
					
						
							| 
									
										
										
										
											2022-03-29 11:54:56 +02:00
										 |  |  | 	suite.accountProcessor = account.New(suite.db, suite.tc, suite.mediaManager, suite.oauthServer, suite.fromClientAPIChan, suite.federator, processing.GetParseMentionFunc(suite.db, suite.federator)) | 
					
						
							| 
									
										
										
										
											2021-09-10 14:36:10 +02:00
										 |  |  | 	testrig.StandardDBSetup(suite.db, nil) | 
					
						
							|  |  |  | 	testrig.StandardStorageSetup(suite.storage, "../../../testrig/media") | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (suite *AccountStandardTestSuite) TearDownTest() { | 
					
						
							|  |  |  | 	testrig.StandardDBTeardown(suite.db) | 
					
						
							|  |  |  | 	testrig.StandardStorageTeardown(suite.storage) | 
					
						
							|  |  |  | } |