| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | /* | 
					
						
							|  |  |  |    GoToSocial | 
					
						
							| 
									
										
										
										
											2021-12-20 18:42:19 +01:00
										 |  |  |    Copyright (C) 2021-2022 GoToSocial Authors admin@gotosocial.org | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +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 federation_test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"github.com/stretchr/testify/suite" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/db" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" | 
					
						
							| 
									
										
										
										
											2022-07-03 12:08:30 +02:00
										 |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/storage" | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | 	"github.com/superseriousbusiness/gotosocial/internal/typeutils" | 
					
						
							|  |  |  | 	"github.com/superseriousbusiness/gotosocial/testrig" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-29 15:05:13 +02:00
										 |  |  | type FederatorStandardTestSuite struct { | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | 	suite.Suite | 
					
						
							| 
									
										
										
										
											2022-04-29 15:53:04 +02:00
										 |  |  | 	db             db.DB | 
					
						
							| 
									
										
										
										
											2022-07-03 12:08:30 +02:00
										 |  |  | 	storage        storage.Driver | 
					
						
							| 
									
										
										
										
											2022-04-29 15:53:04 +02:00
										 |  |  | 	tc             typeutils.TypeConverter | 
					
						
							|  |  |  | 	testAccounts   map[string]*gtsmodel.Account | 
					
						
							| 
									
										
										
										
											2022-05-23 11:46:50 +02:00
										 |  |  | 	testStatuses   map[string]*gtsmodel.Status | 
					
						
							| 
									
										
										
										
											2022-04-29 15:53:04 +02:00
										 |  |  | 	testActivities map[string]testrig.ActivityWithSignature | 
					
						
							| 
									
										
										
										
											2022-11-11 12:18:38 +01:00
										 |  |  | 	testTombstones map[string]*gtsmodel.Tombstone | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // SetupSuite sets some variables on the suite that we can use as consts (more or less) throughout | 
					
						
							| 
									
										
										
										
											2022-04-29 15:05:13 +02:00
										 |  |  | func (suite *FederatorStandardTestSuite) SetupSuite() { | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | 	// setup standard items | 
					
						
							| 
									
										
										
										
											2022-07-03 12:08:30 +02:00
										 |  |  | 	suite.storage = testrig.NewInMemoryStorage() | 
					
						
							| 
									
										
										
										
											2022-04-29 15:53:04 +02:00
										 |  |  | 	suite.tc = testrig.NewTestTypeConverter(suite.db) | 
					
						
							|  |  |  | 	suite.testAccounts = testrig.NewTestAccounts() | 
					
						
							| 
									
										
										
										
											2022-05-23 11:46:50 +02:00
										 |  |  | 	suite.testStatuses = testrig.NewTestStatuses() | 
					
						
							| 
									
										
										
										
											2022-11-11 12:18:38 +01:00
										 |  |  | 	suite.testTombstones = testrig.NewTestTombstones() | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-29 15:05:13 +02:00
										 |  |  | func (suite *FederatorStandardTestSuite) SetupTest() { | 
					
						
							| 
									
										
										
										
											2021-12-07 13:31:39 +01:00
										 |  |  | 	testrig.InitTestConfig() | 
					
						
							| 
									
										
										
										
											2022-04-29 15:05:13 +02:00
										 |  |  | 	testrig.InitTestLog() | 
					
						
							| 
									
										
										
										
											2021-12-07 13:31:39 +01:00
										 |  |  | 	suite.db = testrig.NewTestDB() | 
					
						
							| 
									
										
										
										
											2022-04-29 15:53:04 +02:00
										 |  |  | 	suite.testActivities = testrig.NewTestActivities(suite.testAccounts) | 
					
						
							|  |  |  | 	testrig.StandardDBSetup(suite.db, suite.testAccounts) | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // TearDownTest drops tables to make sure there's no data in the db | 
					
						
							| 
									
										
										
										
											2022-04-29 15:05:13 +02:00
										 |  |  | func (suite *FederatorStandardTestSuite) TearDownTest() { | 
					
						
							| 
									
										
										
										
											2021-05-08 14:25:55 +02:00
										 |  |  | 	testrig.StandardDBTeardown(suite.db) | 
					
						
							|  |  |  | } |