diff options
author | 2023-05-25 10:37:38 +0200 | |
---|---|---|
committer | 2023-05-25 10:37:38 +0200 | |
commit | f5c004d67d4ed66b6c6df100afec47174aa14ae0 (patch) | |
tree | 45b72a6e90450d711e10571d844138186fe023c9 /testrig | |
parent | [docs] local docs hacking howto (#1816) (diff) | |
download | gotosocial-f5c004d67d4ed66b6c6df100afec47174aa14ae0.tar.xz |
[feature] Add List functionality (#1802)
* start working on lists
* further list work
* test list db functions nicely
* more work on lists
* peepoopeepoo
* poke
* start list timeline func
* we're getting there lads
* couldn't be me working on stuff... could it?
* hook up handlers
* fiddling
* weeee
* woah
* screaming, pissing
* fix streaming being a whiny baby
* lint, small test fix, swagger
* tidying up, testing
* fucked! by the linter
* move timelines to state like a boss
* add timeline start to tests using state
* invalidate lists
Diffstat (limited to 'testrig')
-rw-r--r-- | testrig/config.go | 2 | ||||
-rw-r--r-- | testrig/db.go | 14 | ||||
-rw-r--r-- | testrig/testmodels.go | 32 | ||||
-rw-r--r-- | testrig/util.go | 27 |
4 files changed, 74 insertions, 1 deletions
diff --git a/testrig/config.go b/testrig/config.go index dea8ee641..aeac78e3f 100644 --- a/testrig/config.go +++ b/testrig/config.go @@ -33,7 +33,7 @@ func InitTestConfig() { } var testDefaults = config.Configuration{ - LogLevel: "info", + LogLevel: "trace", LogDbQueries: true, ApplicationName: "gotosocial", LandingPageUser: "", diff --git a/testrig/db.go b/testrig/db.go index d95c8f941..c169669d7 100644 --- a/testrig/db.go +++ b/testrig/db.go @@ -39,6 +39,8 @@ var testModels = []interface{}{ >smodel.EmailDomainBlock{}, >smodel.Follow{}, >smodel.FollowRequest{}, + >smodel.List{}, + >smodel.ListEntry{}, >smodel.MediaAttachment{}, >smodel.Mention{}, >smodel.Status{}, @@ -248,6 +250,18 @@ func StandardDBSetup(db db.DB, accounts map[string]*gtsmodel.Account) { } } + for _, v := range NewTestLists() { + if err := db.Put(ctx, v); err != nil { + log.Panic(nil, err) + } + } + + for _, v := range NewTestListEntries() { + if err := db.Put(ctx, v); err != nil { + log.Panic(nil, err) + } + } + for _, v := range NewTestNotifications() { if err := db.Put(ctx, v); err != nil { log.Panic(nil, err) diff --git a/testrig/testmodels.go b/testrig/testmodels.go index 15e204f85..c55b80e60 100644 --- a/testrig/testmodels.go +++ b/testrig/testmodels.go @@ -1961,6 +1961,38 @@ func NewTestFollows() map[string]*gtsmodel.Follow { } } +func NewTestLists() map[string]*gtsmodel.List { + return map[string]*gtsmodel.List{ + "local_account_1_list_1": { + ID: "01H0G8E4Q2J3FE3JDWJVWEDCD1", + CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"), + UpdatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"), + Title: "Cool Ass Posters From This Instance", + AccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", + RepliesPolicy: gtsmodel.RepliesPolicyFollowed, + }, + } +} + +func NewTestListEntries() map[string]*gtsmodel.ListEntry { + return map[string]*gtsmodel.ListEntry{ + "local_account_1_list_1_entry_1": { + ID: "01H0G89MWVQE0M58VD2HQYMQWH", + CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"), + UpdatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"), + ListID: "01H0G8E4Q2J3FE3JDWJVWEDCD1", + FollowID: "01F8PYDCE8XE23GRE5DPZJDZDP", + }, + "local_account_1_list_1_entry_2": { + ID: "01H0G8FFM1AGQDRNGBGGX8CYJQ", + CreatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"), + UpdatedAt: TimeMustParse("2022-05-14T13:21:09+02:00"), + ListID: "01H0G8E4Q2J3FE3JDWJVWEDCD1", + FollowID: "01F8PY8RHWRQZV038T4E8T9YK8", + }, + } +} + func NewTestBlocks() map[string]*gtsmodel.Block { return map[string]*gtsmodel.Block{ "local_account_2_block_remote_account_1": { diff --git a/testrig/util.go b/testrig/util.go index d7183df1c..4e52d12b5 100644 --- a/testrig/util.go +++ b/testrig/util.go @@ -20,6 +20,7 @@ package testrig import ( "bytes" "context" + "fmt" "io" "mime/multipart" "net/url" @@ -27,7 +28,11 @@ import ( "time" "github.com/superseriousbusiness/gotosocial/internal/messages" + tlprocessor "github.com/superseriousbusiness/gotosocial/internal/processing/timeline" "github.com/superseriousbusiness/gotosocial/internal/state" + "github.com/superseriousbusiness/gotosocial/internal/timeline" + "github.com/superseriousbusiness/gotosocial/internal/typeutils" + "github.com/superseriousbusiness/gotosocial/internal/visibility" ) func StartWorkers(state *state.State) { @@ -47,6 +52,28 @@ func StopWorkers(state *state.State) { _ = state.Workers.Media.Stop() } +func StartTimelines(state *state.State, filter *visibility.Filter, typeConverter typeutils.TypeConverter) { + state.Timelines.Home = timeline.NewManager( + tlprocessor.HomeTimelineGrab(state), + tlprocessor.HomeTimelineFilter(state, filter), + tlprocessor.HomeTimelineStatusPrepare(state, typeConverter), + tlprocessor.SkipInsert(), + ) + if err := state.Timelines.Home.Start(); err != nil { + panic(fmt.Sprintf("error starting home timeline: %s", err)) + } + + state.Timelines.List = timeline.NewManager( + tlprocessor.ListTimelineGrab(state), + tlprocessor.ListTimelineFilter(state, filter), + tlprocessor.ListTimelineStatusPrepare(state, typeConverter), + tlprocessor.SkipInsert(), + ) + if err := state.Timelines.List.Start(); err != nil { + panic(fmt.Sprintf("error starting list timeline: %s", err)) + } +} + // CreateMultipartFormData is a handy function for taking a fieldname and a filename, and creating a multipart form bytes buffer // with the file contents set in the given fieldname. The extraFields param can be used to add extra FormFields to the request, as necessary. // The returned bytes.Buffer b can be used like so: |