mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-09 08:27:32 -04:00
This PR allows `init_tracing_for_test` to be called by any other crate in the sdk Signed-off-by: multi [multiestunhappydev@gmail.com](mailto:multiestunhappydev@gmail.com)
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
// The http mocking library is not supported for wasm32
|
|
#![cfg(not(target_family = "wasm"))]
|
|
use matrix_sdk::test_utils::logged_in_client_with_server;
|
|
use serde::Serialize;
|
|
use wiremock::{
|
|
matchers::{header, method, path, query_param, query_param_is_missing},
|
|
Mock, MockServer, ResponseTemplate,
|
|
};
|
|
|
|
mod account;
|
|
mod client;
|
|
#[cfg(feature = "e2e-encryption")]
|
|
mod encryption;
|
|
mod event_cache;
|
|
mod matrix_auth;
|
|
mod media;
|
|
mod notification;
|
|
mod refresh_token;
|
|
mod room;
|
|
mod room_preview;
|
|
mod send_queue;
|
|
#[cfg(feature = "experimental-widgets")]
|
|
mod widget;
|
|
|
|
matrix_sdk_test_utils::init_tracing_for_tests!();
|
|
|
|
/// Mount a Mock on the given server to handle the `GET /sync` endpoint with
|
|
/// an optional `since` param that returns a 200 status code with the given
|
|
/// response body.
|
|
async fn mock_sync(server: &MockServer, response_body: impl Serialize, since: Option<String>) {
|
|
let mut builder = Mock::given(method("GET"))
|
|
.and(path("/_matrix/client/r0/sync"))
|
|
.and(header("authorization", "Bearer 1234"));
|
|
|
|
if let Some(since) = since {
|
|
builder = builder.and(query_param("since", since));
|
|
} else {
|
|
builder = builder.and(query_param_is_missing("since"));
|
|
}
|
|
|
|
builder
|
|
.respond_with(ResponseTemplate::new(200).set_body_json(response_body))
|
|
.mount(server)
|
|
.await;
|
|
}
|