mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-13 23:07:27 -06:00
[bugfix/chore] Refactor timeline code (#1656)
* start poking timelines * OK yes we're refactoring, but it's nothing like the last time so don't worry * more fiddling * update tests, simplify Get * thanks linter, you're the best, mwah mwah kisses * do a bit more tidying up * start buggering about with the prepare function * fix little oopsie * start merging lists into 1 * ik heb een heel zwaar leven nee nee echt waar * hey it works we did it reddit * regenerate swagger docs * tidy up a wee bit * adjust paging * fix little error, remove unused functions
This commit is contained in:
parent
c54510bc74
commit
3510454768
22 changed files with 1319 additions and 1365 deletions
|
|
@ -52,7 +52,7 @@ func (suite *IndexTestSuite) SetupTest() {
|
|||
testrig.StandardDBSetup(suite.db, nil)
|
||||
|
||||
// let's take local_account_1 as the timeline owner, and start with an empty timeline
|
||||
tl, err := timeline.NewTimeline(
|
||||
suite.timeline = timeline.NewTimeline(
|
||||
context.Background(),
|
||||
suite.testAccounts["local_account_1"].ID,
|
||||
processing.StatusGrabFunction(suite.db),
|
||||
|
|
@ -60,10 +60,6 @@ func (suite *IndexTestSuite) SetupTest() {
|
|||
processing.StatusPrepareFunction(suite.db, suite.tc),
|
||||
processing.StatusSkipInsertFunction(),
|
||||
)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
suite.timeline = tl
|
||||
}
|
||||
|
||||
func (suite *IndexTestSuite) TearDownTest() {
|
||||
|
|
@ -72,12 +68,11 @@ func (suite *IndexTestSuite) TearDownTest() {
|
|||
|
||||
func (suite *IndexTestSuite) TestOldestIndexedItemIDEmpty() {
|
||||
// the oldest indexed post should be an empty string since there's nothing indexed yet
|
||||
postID, err := suite.timeline.OldestIndexedItemID(context.Background())
|
||||
suite.NoError(err)
|
||||
postID := suite.timeline.OldestIndexedItemID()
|
||||
suite.Empty(postID)
|
||||
|
||||
// indexLength should be 0
|
||||
indexLength := suite.timeline.ItemIndexLength(context.Background())
|
||||
indexLength := suite.timeline.Len()
|
||||
suite.Equal(0, indexLength)
|
||||
}
|
||||
|
||||
|
|
@ -85,12 +80,12 @@ func (suite *IndexTestSuite) TestIndexAlreadyIndexed() {
|
|||
testStatus := suite.testStatuses["local_account_1_status_1"]
|
||||
|
||||
// index one post -- it should be indexed
|
||||
indexed, err := suite.timeline.IndexOne(context.Background(), testStatus.ID, testStatus.BoostOfID, testStatus.AccountID, testStatus.BoostOfAccountID)
|
||||
indexed, err := suite.timeline.IndexAndPrepareOne(context.Background(), testStatus.ID, testStatus.BoostOfID, testStatus.AccountID, testStatus.BoostOfAccountID)
|
||||
suite.NoError(err)
|
||||
suite.True(indexed)
|
||||
|
||||
// try to index the same post again -- it should not be indexed
|
||||
indexed, err = suite.timeline.IndexOne(context.Background(), testStatus.ID, testStatus.BoostOfID, testStatus.AccountID, testStatus.BoostOfAccountID)
|
||||
indexed, err = suite.timeline.IndexAndPrepareOne(context.Background(), testStatus.ID, testStatus.BoostOfID, testStatus.AccountID, testStatus.BoostOfAccountID)
|
||||
suite.NoError(err)
|
||||
suite.False(indexed)
|
||||
}
|
||||
|
|
@ -120,12 +115,12 @@ func (suite *IndexTestSuite) TestIndexBoostOfAlreadyIndexed() {
|
|||
}
|
||||
|
||||
// index one post -- it should be indexed
|
||||
indexed, err := suite.timeline.IndexOne(context.Background(), testStatus.ID, testStatus.BoostOfID, testStatus.AccountID, testStatus.BoostOfAccountID)
|
||||
indexed, err := suite.timeline.IndexAndPrepareOne(context.Background(), testStatus.ID, testStatus.BoostOfID, testStatus.AccountID, testStatus.BoostOfAccountID)
|
||||
suite.NoError(err)
|
||||
suite.True(indexed)
|
||||
|
||||
// try to index the a boost of that post -- it should not be indexed
|
||||
indexed, err = suite.timeline.IndexOne(context.Background(), boostOfTestStatus.ID, boostOfTestStatus.BoostOfID, boostOfTestStatus.AccountID, boostOfTestStatus.BoostOfAccountID)
|
||||
indexed, err = suite.timeline.IndexAndPrepareOne(context.Background(), boostOfTestStatus.ID, boostOfTestStatus.BoostOfID, boostOfTestStatus.AccountID, boostOfTestStatus.BoostOfAccountID)
|
||||
suite.NoError(err)
|
||||
suite.False(indexed)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue