diff --git a/src/lib.rs b/src/lib.rs index ecee76fe..add6426c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ pub use crate::{error::Error, session::Session}; pub use reqwest::header::InvalidHeaderValue; pub use ruma_client_api as api; pub use ruma_events as events; +pub use ruma_identifiers as identifiers; mod async_client; mod base_client; diff --git a/tests/async_client_tests.rs b/tests/async_client_tests.rs index 116854c8..ab0c4b10 100644 --- a/tests/async_client_tests.rs +++ b/tests/async_client_tests.rs @@ -1,9 +1,13 @@ -use matrix_nio::{AsyncClient, AsyncClientConfig}; -use mockito::mock; -use std::str::FromStr; +use matrix_nio::identifiers::UserId; +use matrix_nio::{AsyncClient, Session, SyncSettings}; + +use mockito::{mock, Matcher}; use tokio::runtime::Runtime; use url::Url; +use std::convert::TryFrom; +use std::str::FromStr; + #[test] fn login() { let rt = Runtime::new().unwrap(); @@ -22,3 +26,30 @@ fn login() { assert!(client.logged_in(), "Clint should be logged in"); } + +#[test] +fn sync() { + let rt = Runtime::new().unwrap(); + + let homeserver = Url::from_str(&mockito::server_url()).unwrap(); + + let session = Session { + access_token: "1234".to_owned(), + user_id: UserId::try_from("@example:example.com").unwrap(), + device_id: "DEVICEID".to_owned(), + }; + + let _m = mock( + "GET", + Matcher::Regex(r"^/_matrix/client/r0/sync\?.*$".to_string()), + ) + .with_status(200) + .with_body_from_file("tests/data/sync.json") + .create(); + + let mut client = AsyncClient::new(homeserver, Some(session)).unwrap(); + + let sync_settings = SyncSettings::new().timeout(3000).unwrap(); + + rt.block_on(client.sync(sync_settings)).unwrap(); +} diff --git a/tests/data/sync.json b/tests/data/sync.json index a43cb577..3b898e20 100644 --- a/tests/data/sync.json +++ b/tests/data/sync.json @@ -218,5 +218,9 @@ }, "to_device": { "events": [] + }, + + "presence": { + "events": [] } }