summaryrefslogtreecommitdiff
path: root/internal/timeline/prune_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/timeline/prune_test.go')
-rw-r--r--internal/timeline/prune_test.go25
1 files changed, 16 insertions, 9 deletions
diff --git a/internal/timeline/prune_test.go b/internal/timeline/prune_test.go
index 7daf88b83..89164563b 100644
--- a/internal/timeline/prune_test.go
+++ b/internal/timeline/prune_test.go
@@ -52,7 +52,7 @@ func (suite *PruneTestSuite) SetupTest() {
testrig.StandardDBSetup(suite.db, nil)
// let's take local_account_1 as the timeline owner
- tl, err := timeline.NewTimeline(
+ tl := timeline.NewTimeline(
context.Background(),
suite.testAccounts["local_account_1"].ID,
processing.StatusGrabFunction(suite.db),
@@ -60,9 +60,6 @@ func (suite *PruneTestSuite) SetupTest() {
processing.StatusPrepareFunction(suite.db, suite.tc),
processing.StatusSkipInsertFunction(),
)
- if err != nil {
- suite.FailNow(err.Error())
- }
// put the status IDs in a determinate order since we can't trust a map to keep its order
statuses := []*gtsmodel.Status{}
@@ -90,20 +87,30 @@ func (suite *PruneTestSuite) TearDownTest() {
func (suite *PruneTestSuite) TestPrune() {
// prune down to 5 prepared + 5 indexed
- suite.Equal(24, suite.timeline.Prune(5, 5))
- suite.Equal(5, suite.timeline.ItemIndexLength(context.Background()))
+ suite.Equal(12, suite.timeline.Prune(5, 5))
+ suite.Equal(5, suite.timeline.Len())
+}
+
+func (suite *PruneTestSuite) TestPruneTwice() {
+ // prune down to 5 prepared + 10 indexed
+ suite.Equal(12, suite.timeline.Prune(5, 10))
+ suite.Equal(10, suite.timeline.Len())
+
+ // Prune same again, nothing should be pruned this time.
+ suite.Zero(suite.timeline.Prune(5, 10))
+ suite.Equal(10, suite.timeline.Len())
}
func (suite *PruneTestSuite) TestPruneTo0() {
// prune down to 0 prepared + 0 indexed
- suite.Equal(34, suite.timeline.Prune(0, 0))
- suite.Equal(0, suite.timeline.ItemIndexLength(context.Background()))
+ suite.Equal(17, suite.timeline.Prune(0, 0))
+ suite.Equal(0, suite.timeline.Len())
}
func (suite *PruneTestSuite) TestPruneToInfinityAndBeyond() {
// prune to 99999, this should result in no entries being pruned
suite.Equal(0, suite.timeline.Prune(99999, 99999))
- suite.Equal(17, suite.timeline.ItemIndexLength(context.Background()))
+ suite.Equal(17, suite.timeline.Len())
}
func TestPruneTestSuite(t *testing.T) {