Description
The EventBuilder
struct/methods and sync_timeline_event!
macros are used all over the place, but they're quite verbose and not the easier to use, when usually tests want simple things ("a plain text message with that content sent from this user") and don't care about low-level Matrix details.
So as to improve this, I've added an EventFactory
struct that makes it easier to write such events, by chaining calls, and taking care of the fields that always need to be set (if necessary).
It would be great to fully get rid of EventBuilder
and sync_timeline_event!
, so we don't have three ways of defining test events, but a single one. I've started migrating in a few PRs, but I think this is a great way to get accointed with the code base by making relatively simple changes:
- look at a use of
EventBuilder
orsync_timeline_event!
- consider if it can be replaced by using an
EventFactory
instead- if yes, do the replacement
- some tests do already have an
EventFactory
, often calledfactory
, or a plainf
in the code; reuse those if present, or follow that same naming convention for new uses.
- some tests do already have an
- if no: consider adding new methods/helpers to the
EventFactory
. This might be a bit more involved, so if you're chasing the good first issue part of this issue, then I'd recommend doing the plain replacements instead, aka the previous bullet item.
- if yes, do the replacement