Skip to content

Commit 9c244c3

Browse files
bnjbvrandybalaam
authored andcommitted
test(event cache): use the MatrixMockServer for integration testing
1 parent 2d0676c commit 9c244c3

File tree

3 files changed

+180
-224
lines changed

3 files changed

+180
-224
lines changed

crates/matrix-sdk/src/test_utils/mocks.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,11 @@ impl<'a> MockEndpoint<'a, RoomMessagesEndpoint> {
14061406
Self { mock: self.mock.and(query_param("limit", limit.to_string())), ..self }
14071407
}
14081408

1409+
/// Expects an optional `from` to be set on the request.
1410+
pub fn from(self, from: &str) -> Self {
1411+
Self { mock: self.mock.and(query_param("from", from)), ..self }
1412+
}
1413+
14091414
/// Returns a messages endpoint that emulates success, i.e. the messages
14101415
/// provided as `response` could be retrieved.
14111416
///
@@ -1416,13 +1421,13 @@ impl<'a> MockEndpoint<'a, RoomMessagesEndpoint> {
14161421
start: String,
14171422
end: Option<String>,
14181423
chunk: Vec<impl Into<Raw<AnyTimelineEvent>>>,
1419-
state: Vec<impl Into<Raw<AnyStateEvent>>>,
1424+
state: Vec<Raw<AnyStateEvent>>,
14201425
) -> MatrixMock<'a> {
14211426
let mock = self.mock.respond_with(ResponseTemplate::new(200).set_body_json(json!({
14221427
"start": start,
14231428
"end": end,
14241429
"chunk": chunk.into_iter().map(|ev| ev.into()).collect::<Vec<_>>(),
1425-
"state": state.into_iter().map(|ev| ev.into()).collect::<Vec<_>>(),
1430+
"state": state,
14261431
})));
14271432
MatrixMock { server: self.server, mock }
14281433
}

0 commit comments

Comments
 (0)