mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 17:52:24 -05:00
[chore] Timeline test updates (#578)
* add admin boost of zork to test model * update tests to make them more determinate * remove printf call
This commit is contained in:
parent
27a3c1dc56
commit
5ef41ba3f2
5 changed files with 58 additions and 21 deletions
|
|
@ -20,10 +20,12 @@ package timeline_test
|
|||
|
||||
import (
|
||||
"context"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/timeline"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
|
|
@ -62,8 +64,17 @@ func (suite *GetTestSuite) SetupTest() {
|
|||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// prepare the timeline by just shoving all test statuses in it -- let's not be fussy about who sees what
|
||||
// put the status IDs in a determinate order since we can't trust a map to keep its order
|
||||
statuses := []*gtsmodel.Status{}
|
||||
for _, s := range suite.testStatuses {
|
||||
statuses = append(statuses, s)
|
||||
}
|
||||
sort.Slice(statuses, func(i, j int) bool {
|
||||
return statuses[i].ID > statuses[j].ID
|
||||
})
|
||||
|
||||
// prepare the timeline by just shoving all test statuses in it -- let's not be fussy about who sees what
|
||||
for _, s := range statuses {
|
||||
_, err := tl.IndexAndPrepareOne(context.Background(), s.GetID(), s.BoostOfID, s.AccountID, s.BoostOfAccountID)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
|
|
@ -85,7 +96,7 @@ func (suite *GetTestSuite) TestGetDefault() {
|
|||
}
|
||||
|
||||
// we only have 16 statuses in the test suite
|
||||
suite.Len(statuses, 16)
|
||||
suite.Len(statuses, 17)
|
||||
|
||||
// statuses should be sorted highest to lowest ID
|
||||
var highest string
|
||||
|
|
@ -171,14 +182,14 @@ func (suite *GetTestSuite) TestGetMaxIDPrepareNext() {
|
|||
}
|
||||
|
||||
func (suite *GetTestSuite) TestGetMinID() {
|
||||
// ask for 10 with a min ID somewhere in the middle of the stack
|
||||
// ask for 15 with a min ID somewhere in the middle of the stack
|
||||
statuses, err := suite.timeline.Get(context.Background(), 10, "", "01F8MHBQCBTDKN6X5VHGMMN4MA", "", false)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// we should only get 9 statuses back, since we asked for a min ID that excludes some of our entries
|
||||
suite.Len(statuses, 9)
|
||||
// we should only get 10 statuses back, since we asked for a min ID that excludes some of our entries
|
||||
suite.Len(statuses, 10)
|
||||
|
||||
// statuses should be sorted highest to lowest ID
|
||||
var highest string
|
||||
|
|
@ -193,14 +204,14 @@ func (suite *GetTestSuite) TestGetMinID() {
|
|||
}
|
||||
|
||||
func (suite *GetTestSuite) TestGetSinceID() {
|
||||
// ask for 10 with a since ID somewhere in the middle of the stack
|
||||
statuses, err := suite.timeline.Get(context.Background(), 10, "", "", "01F8MHBQCBTDKN6X5VHGMMN4MA", false)
|
||||
// ask for 15 with a since ID somewhere in the middle of the stack
|
||||
statuses, err := suite.timeline.Get(context.Background(), 15, "", "", "01F8MHBQCBTDKN6X5VHGMMN4MA", false)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// we should only get 9 statuses back, since we asked for a since ID that excludes some of our entries
|
||||
suite.Len(statuses, 9)
|
||||
// we should only get 10 statuses back, since we asked for a since ID that excludes some of our entries
|
||||
suite.Len(statuses, 10)
|
||||
|
||||
// statuses should be sorted highest to lowest ID
|
||||
var highest string
|
||||
|
|
@ -215,14 +226,14 @@ func (suite *GetTestSuite) TestGetSinceID() {
|
|||
}
|
||||
|
||||
func (suite *GetTestSuite) TestGetSinceIDPrepareNext() {
|
||||
// ask for 10 with a since ID somewhere in the middle of the stack
|
||||
statuses, err := suite.timeline.Get(context.Background(), 10, "", "", "01F8MHBQCBTDKN6X5VHGMMN4MA", true)
|
||||
// ask for 15 with a since ID somewhere in the middle of the stack
|
||||
statuses, err := suite.timeline.Get(context.Background(), 15, "", "", "01F8MHBQCBTDKN6X5VHGMMN4MA", true)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
// we should only get 9 statuses back, since we asked for a since ID that excludes some of our entries
|
||||
suite.Len(statuses, 9)
|
||||
// we should only get 10 statuses back, since we asked for a since ID that excludes some of our entries
|
||||
suite.Len(statuses, 10)
|
||||
|
||||
// statuses should be sorted highest to lowest ID
|
||||
var highest string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue