diff options
author | 2023-08-22 15:41:51 +0200 | |
---|---|---|
committer | 2023-08-22 15:41:51 +0200 | |
commit | 94d16631bc0b6b5aa2900a5b059cd80c524c3eb9 (patch) | |
tree | 680fb0bf37b4d2b926824ef3091a5db7daa18b43 /internal/db/bundb/timeline_test.go | |
parent | [feature] Make log format configurable (#2130) (diff) | |
download | gotosocial-94d16631bc0b6b5aa2900a5b059cd80c524c3eb9.tar.xz |
[performance] Rework home timeline query to use cache more (#2148)
Diffstat (limited to 'internal/db/bundb/timeline_test.go')
-rw-r--r-- | internal/db/bundb/timeline_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/db/bundb/timeline_test.go b/internal/db/bundb/timeline_test.go index 2bc9c9d0d..e5a78dfd1 100644 --- a/internal/db/bundb/timeline_test.go +++ b/internal/db/bundb/timeline_test.go @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/ap" + "github.com/superseriousbusiness/gotosocial/internal/gtscontext" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/util" @@ -156,6 +157,38 @@ func (suite *TimelineTestSuite) TestGetHomeTimeline() { suite.checkStatuses(s, id.Highest, id.Lowest, 16) } +func (suite *TimelineTestSuite) TestGetHomeTimelineNoFollowing() { + var ( + ctx = context.Background() + viewingAccount = suite.testAccounts["local_account_1"] + ) + + // Remove all of viewingAccount's follows. + follows, err := suite.state.DB.GetAccountFollows( + gtscontext.SetBarebones(ctx), + viewingAccount.ID, + ) + + if err != nil { + suite.FailNow(err.Error()) + } + + for _, f := range follows { + if err := suite.state.DB.DeleteFollowByID(ctx, f.ID); err != nil { + suite.FailNow(err.Error()) + } + } + + // Query should work fine; though far + // fewer statuses will be returned ofc. + s, err := suite.db.GetHomeTimeline(ctx, viewingAccount.ID, "", "", "", 20, false) + if err != nil { + suite.FailNow(err.Error()) + } + + suite.checkStatuses(s, id.Highest, id.Lowest, 5) +} + func (suite *TimelineTestSuite) TestGetHomeTimelineWithFutureStatus() { var ( ctx = context.Background() |