mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-11-03 18:02:26 -06:00 
			
		
		
		
	An implementation of [`scheduled_statuses`](https://docs.joinmastodon.org/methods/scheduled_statuses/). Will fix #1006. this is heavily WIP and I need to reorganize some of the code, working on this made me somehow familiar with the codebase and led to my other recent contributions i told some fops on fedi i'd work on this so i have no choice but to complete it 🤷♀️ btw iirc my avatar presents me working on this branch Signed-off-by: nicole mikołajczyk <git@mkljczk.pl> Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4274 Co-authored-by: nicole mikołajczyk <git@mkljczk.pl> Co-committed-by: nicole mikołajczyk <git@mkljczk.pl>
		
			
				
	
	
		
			130 lines
		
	
	
	
		
			5.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			130 lines
		
	
	
	
		
			5.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// GoToSocial
 | 
						|
// Copyright (C) GoToSocial Authors admin@gotosocial.org
 | 
						|
// SPDX-License-Identifier: AGPL-3.0-or-later
 | 
						|
//
 | 
						|
// 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 status_test
 | 
						|
 | 
						|
import (
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/admin"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/db"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/federation"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/filter/interaction"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/filter/mutes"
 | 
						|
	statusfilter "code.superseriousbusiness.org/gotosocial/internal/filter/status"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/filter/visibility"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/media"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/processing"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/processing/common"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/processing/interactionrequests"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/processing/polls"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/processing/status"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/state"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/storage"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/transport"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/internal/typeutils"
 | 
						|
	"code.superseriousbusiness.org/gotosocial/testrig"
 | 
						|
	"github.com/stretchr/testify/suite"
 | 
						|
)
 | 
						|
 | 
						|
type StatusStandardTestSuite struct {
 | 
						|
	suite.Suite
 | 
						|
	db            db.DB
 | 
						|
	typeConverter *typeutils.Converter
 | 
						|
	tc            transport.Controller
 | 
						|
	storage       *storage.Driver
 | 
						|
	state         state.State
 | 
						|
	mediaManager  *media.Manager
 | 
						|
	federator     *federation.Federator
 | 
						|
 | 
						|
	// standard suite models
 | 
						|
	testTokens            map[string]*gtsmodel.Token
 | 
						|
	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
 | 
						|
	testTags              map[string]*gtsmodel.Tag
 | 
						|
	testMentions          map[string]*gtsmodel.Mention
 | 
						|
	testScheduledStatuses map[string]*gtsmodel.ScheduledStatus
 | 
						|
 | 
						|
	// module being tested
 | 
						|
	status status.Processor
 | 
						|
}
 | 
						|
 | 
						|
func (suite *StatusStandardTestSuite) SetupSuite() {
 | 
						|
	suite.testTokens = testrig.NewTestTokens()
 | 
						|
	suite.testApplications = testrig.NewTestApplications()
 | 
						|
	suite.testUsers = testrig.NewTestUsers()
 | 
						|
	suite.testAccounts = testrig.NewTestAccounts()
 | 
						|
	suite.testAttachments = testrig.NewTestAttachments()
 | 
						|
	suite.testStatuses = testrig.NewTestStatuses()
 | 
						|
	suite.testTags = testrig.NewTestTags()
 | 
						|
	suite.testMentions = testrig.NewTestMentions()
 | 
						|
	suite.testScheduledStatuses = testrig.NewTestScheduledStatuses()
 | 
						|
}
 | 
						|
 | 
						|
func (suite *StatusStandardTestSuite) SetupTest() {
 | 
						|
	suite.state.Caches.Init()
 | 
						|
	testrig.StartNoopWorkers(&suite.state)
 | 
						|
 | 
						|
	testrig.InitTestConfig()
 | 
						|
	testrig.InitTestLog()
 | 
						|
 | 
						|
	suite.db = testrig.NewTestDB(&suite.state)
 | 
						|
	suite.typeConverter = typeutils.NewConverter(&suite.state)
 | 
						|
	suite.state.DB = suite.db
 | 
						|
	suite.state.AdminActions = admin.New(suite.state.DB, &suite.state.Workers)
 | 
						|
 | 
						|
	suite.tc = testrig.NewTestTransportController(&suite.state, testrig.NewMockHTTPClient(nil, "../../../testrig/media"))
 | 
						|
	suite.storage = testrig.NewInMemoryStorage()
 | 
						|
	suite.state.Storage = suite.storage
 | 
						|
	suite.mediaManager = testrig.NewTestMediaManager(&suite.state)
 | 
						|
	suite.federator = testrig.NewTestFederator(&suite.state, suite.tc, suite.mediaManager)
 | 
						|
 | 
						|
	visFilter := visibility.NewFilter(&suite.state)
 | 
						|
	muteFilter := mutes.NewFilter(&suite.state)
 | 
						|
	intFilter := interaction.NewFilter(&suite.state)
 | 
						|
	statusFilter := statusfilter.NewFilter(&suite.state)
 | 
						|
 | 
						|
	common := common.New(&suite.state, suite.mediaManager, suite.typeConverter, suite.federator, visFilter, muteFilter, statusFilter)
 | 
						|
	polls := polls.New(&common, &suite.state, suite.typeConverter)
 | 
						|
	intReqs := interactionrequests.New(&common, &suite.state, suite.typeConverter)
 | 
						|
 | 
						|
	suite.status = status.New(
 | 
						|
		&suite.state,
 | 
						|
		&common,
 | 
						|
		&polls,
 | 
						|
		&intReqs,
 | 
						|
		suite.federator,
 | 
						|
		suite.typeConverter,
 | 
						|
		visFilter,
 | 
						|
		intFilter,
 | 
						|
		processing.GetParseMentionFunc(
 | 
						|
			&suite.state,
 | 
						|
			suite.federator,
 | 
						|
		),
 | 
						|
	)
 | 
						|
 | 
						|
	testrig.StandardDBSetup(suite.db, suite.testAccounts)
 | 
						|
	testrig.StandardStorageSetup(suite.storage, "../../../testrig/media")
 | 
						|
}
 | 
						|
 | 
						|
func (suite *StatusStandardTestSuite) TearDownTest() {
 | 
						|
	testrig.StandardDBTeardown(suite.db)
 | 
						|
	testrig.StandardStorageTeardown(suite.storage)
 | 
						|
	testrig.StopWorkers(&suite.state)
 | 
						|
}
 |