summaryrefslogtreecommitdiff
path: root/internal/timeline/manager_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-04-06 13:43:13 +0200
committerLibravatar GitHub <noreply@github.com>2023-04-06 12:43:13 +0100
commit3510454768b1877540c6dc25f4967e4b608203a8 (patch)
treeaed9c913711f08ae748591271132f968ef1e716f /internal/timeline/manager_test.go
parent[bugfix] Normalize status content (don't parse status content as IRI) (#1665) (diff)
downloadgotosocial-3510454768b1877540c6dc25f4967e4b608203a8.tar.xz
[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
Diffstat (limited to 'internal/timeline/manager_test.go')
-rw-r--r--internal/timeline/manager_test.go40
1 files changed, 9 insertions, 31 deletions
diff --git a/internal/timeline/manager_test.go b/internal/timeline/manager_test.go
index 8fc4984d1..cf1f5be2b 100644
--- a/internal/timeline/manager_test.go
+++ b/internal/timeline/manager_test.go
@@ -72,23 +72,9 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
suite.Equal(0, indexedLen)
// oldestIndexed should be empty string since there's nothing indexed
- oldestIndexed, err := suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
- suite.NoError(err)
+ oldestIndexed := suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
suite.Empty(oldestIndexed)
- // trigger status preparation
- err = suite.manager.PrepareXFromTop(ctx, testAccount.ID, 20)
- suite.NoError(err)
-
- // local_account_1 can see 16 statuses out of the testrig statuses in its home timeline
- indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
- suite.Equal(16, indexedLen)
-
- // oldest should now be set
- oldestIndexed, err = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
- suite.NoError(err)
- suite.Equal("01F8MH75CBF9JFX4ZAD54N0W0R", oldestIndexed)
-
// get hometimeline
statuses, err := suite.manager.GetTimeline(ctx, testAccount.ID, "", "", "", 20, false)
suite.NoError(err)
@@ -103,22 +89,20 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
suite.Equal(15, indexedLen)
// oldest should now be different
- oldestIndexed, err = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
- suite.NoError(err)
+ oldestIndexed = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
suite.Equal("01F8MH82FYRXD2RC6108DAJ5HB", oldestIndexed)
// delete the new oldest status specifically from this timeline, as though local_account_1 had muted or blocked it
removed, err := suite.manager.Remove(ctx, testAccount.ID, "01F8MH82FYRXD2RC6108DAJ5HB")
suite.NoError(err)
- suite.Equal(2, removed) // 1 status should be removed, but from both indexed and prepared, so 2 removals total
+ suite.Equal(1, removed) // 1 status should be removed
// timeline should be shorter
indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
suite.Equal(14, indexedLen)
// oldest should now be different
- oldestIndexed, err = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
- suite.NoError(err)
+ oldestIndexed = suite.manager.GetOldestIndexedID(ctx, testAccount.ID)
suite.Equal("01F8MHAAY43M6RJ473VQFCVH37", oldestIndexed)
// now remove all entries by local_account_2 from the timeline
@@ -129,24 +113,18 @@ func (suite *ManagerTestSuite) TestManagerIntegration() {
indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
suite.Equal(7, indexedLen)
- // ingest 1 into the timeline
- status1 := suite.testStatuses["admin_account_status_1"]
- ingested, err := suite.manager.Ingest(ctx, status1, testAccount.ID)
- suite.NoError(err)
- suite.True(ingested)
-
// ingest and prepare another one into the timeline
- status2 := suite.testStatuses["local_account_2_status_1"]
- ingested, err = suite.manager.IngestAndPrepare(ctx, status2, testAccount.ID)
+ status := suite.testStatuses["local_account_2_status_1"]
+ ingested, err := suite.manager.IngestOne(ctx, testAccount.ID, status)
suite.NoError(err)
suite.True(ingested)
// timeline should be longer now
indexedLen = suite.manager.GetIndexedLength(ctx, testAccount.ID)
- suite.Equal(9, indexedLen)
+ suite.Equal(8, indexedLen)
- // try to ingest status 2 again
- ingested, err = suite.manager.IngestAndPrepare(ctx, status2, testAccount.ID)
+ // try to ingest same status again
+ ingested, err = suite.manager.IngestOne(ctx, testAccount.ID, status)
suite.NoError(err)
suite.False(ingested) // should be false since it's a duplicate
}