Conversation
DMRobertson
left a comment
There was a problem hiding this comment.
Thanks, this looks great!
Two minor questions:
| "github.com/matrix-org/complement/runtime" | ||
| ) | ||
|
|
||
| // Note: In contrast to Sytest, we define a filter.rooms on each search request, this allows us to run in parallel. |
There was a problem hiding this comment.
Is the point that sytest assumes each test was run in isolation, so that there were no other rooms to search for?
There was a problem hiding this comment.
Exactly, Sytest is creating separate a user and room for each test, so would only receive the results from those rooms.
Since we're only using Alice and a new room for each test, we need to filter on the room.
| must.MatchResponse(t, resp, match.HTTPResponse{ | ||
| StatusCode: http.StatusOK, | ||
| JSON: []match.JSON{ | ||
| match.JSONKeyPresent(sce + ".count"), | ||
| match.JSONKeyPresent(sce + ".results"), | ||
| match.JSONKeyEqual(sce+".count", float64(1)), | ||
| match.JSONKeyEqual(result0+".room_id", roomID), | ||
| match.JSONKeyPresent(result0 + ".content"), | ||
| match.JSONKeyPresent(result0 + ".type"), | ||
| match.JSONKeyEqual(result0+".content.body", "Message number 4"), | ||
| match.JSONKeyEqual(resBefore+".0.content.body", "Message number 3"), | ||
| match.JSONKeyEqual(resBefore+".1.content.body", "Message number 2"), | ||
| match.JSONKeyEqual(resAfter+".0.content.body", "Message number 5"), | ||
| match.JSONKeyEqual(resAfter+".1.content.body", "Message number 6"), | ||
| }, |
There was a problem hiding this comment.
It looks like the sytest has some extra checks here. Do we want to carry those over?
next_batchfromassert_json_keys( $room_events, qw( count results next_batch ) );contextfrommy $context = $results->[0]{context}; assert_json_keys( $context, qw( events_before events_after )); my $events_before = $context->{events_before}; my $events_after = $context->{events_after}; assert_eq( scalar @$events_before, 2, 'events_before' ); assert_eq( scalar @$events_after, 2, 'events_after' );
There was a problem hiding this comment.
Oh, seems like I've removed one next_batch check too much.
For context: We're checking
sce := "search_categories.room_events"
result0 := sce + ".results.0.result"
resBefore := sce + ".results.0.context.events_before"
resAfter := sce + ".results.0.context.events_after"
[...]
match.JSONKeyEqual(resBefore+".0.content.body", "Message number 3"),
match.JSONKeyEqual(resBefore+".1.content.body", "Message number 2"),
match.JSONKeyEqual(resAfter+".0.content.body", "Message number 5"),
match.JSONKeyEqual(resAfter+".1.content.body", "Message number 6"),which ensures context as well as the other keys (events_before/after) are present.
There was a problem hiding this comment.
ahh sorry, I missed events_before and events_after. It does all start to blur together if you're not careful!
Adds the tests from tests/43search.pl