[minor] Fewer warnings
This commit is contained in:
parent
1451f41ae3
commit
364c91fed2
5 changed files with 115 additions and 102 deletions
|
@ -9,7 +9,7 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
env_logger = "0.8"
|
env_logger = "0.8"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
tokio = { version = "1.2", features = ["macros", "rt"]}
|
tokio = { version = "1.2", features = ["macros", "rt", "rt-multi-thread"]}
|
||||||
reqwest = "0.11"
|
reqwest = "0.11"
|
||||||
minidom = "0.13"
|
minidom = "0.13"
|
||||||
url = { version = "2.2", features = ["serde"] }
|
url = { version = "2.2", features = ["serde"] }
|
||||||
|
|
17
src/bin/dummy.rs
Normal file
17
src/bin/dummy.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use my_tasks::client::Client;
|
||||||
|
use my_tasks::settings::URL;
|
||||||
|
use my_tasks::settings::USERNAME;
|
||||||
|
use my_tasks::settings::PASSWORD;
|
||||||
|
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
// This is just a function to silence "unused function" warning
|
||||||
|
|
||||||
|
let mut client = Client::new(URL, USERNAME, PASSWORD).unwrap();
|
||||||
|
let calendars = client.get_calendars().await.unwrap();
|
||||||
|
let _ = calendars.iter()
|
||||||
|
.map(|cal| println!(" {}\t{}", cal.name(), cal.url().as_str()))
|
||||||
|
.collect::<()>();
|
||||||
|
let _ = client.get_tasks(&calendars[3].url()).await;
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
//! A `Provider` abstracts these two sources by merging them together into one virtual source. \
|
//! A `Provider` abstracts these two sources by merging them together into one virtual source. \
|
||||||
//! It also handles synchronisation between the local cache and the server.
|
//! It also handles synchronisation between the local cache and the server.
|
||||||
|
|
||||||
mod calendar;
|
pub mod calendar;
|
||||||
pub use calendar::Calendar;
|
pub use calendar::Calendar;
|
||||||
mod task;
|
mod task;
|
||||||
pub use task::Task;
|
pub use task::Task;
|
||||||
|
|
|
@ -46,7 +46,6 @@ pub fn print_xml(element: &Element) {
|
||||||
std::io::stdout(),
|
std::io::stdout(),
|
||||||
0x20, 4
|
0x20, 4
|
||||||
);
|
);
|
||||||
element.to_writer(&mut xml_writer);
|
let _ = element.to_writer(&mut xml_writer);
|
||||||
|
let _ = writer.write(&[0x0a]);
|
||||||
writer.write(&[0x0a]);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,97 +1,94 @@
|
||||||
//! Some tests of a CalDAV client.
|
//! Some tests of a CalDAV client.
|
||||||
//! Most of them are not really integration tests, but just development tests that should be cleaned up one day.
|
//! Most of them are not really integration tests, but just development tests that should be cleaned up one day.
|
||||||
|
|
||||||
use std::error::Error;
|
use reqwest::Method;
|
||||||
use std::convert::TryFrom;
|
use reqwest::header::CONTENT_TYPE;
|
||||||
|
use minidom::Element;
|
||||||
use reqwest::Method;
|
use url::Url;
|
||||||
use reqwest::header::CONTENT_TYPE;
|
|
||||||
use minidom::Element;
|
use my_tasks::client::Client;
|
||||||
use url::Url;
|
use my_tasks::settings::URL;
|
||||||
|
use my_tasks::settings::USERNAME;
|
||||||
use my_tasks::client::Client;
|
use my_tasks::settings::PASSWORD;
|
||||||
use my_tasks::settings::URL;
|
use my_tasks::settings::EXAMPLE_TASK_URL;
|
||||||
use my_tasks::settings::USERNAME;
|
use my_tasks::settings::EXAMPLE_CALENDAR_URL;
|
||||||
use my_tasks::settings::PASSWORD;
|
|
||||||
use my_tasks::settings::EXAMPLE_TASK_URL;
|
static EXAMPLE_TASKS_BODY_LAST_MODIFIED: &str = r#"
|
||||||
use my_tasks::settings::EXAMPLE_CALENDAR_URL;
|
<C:calendar-query xmlns:D="DAV:"
|
||||||
|
xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
static EXAMPLE_TASKS_BODY_LAST_MODIFIED: &str = r#"
|
<D:prop>
|
||||||
<C:calendar-query xmlns:D="DAV:"
|
<D:getetag/>
|
||||||
xmlns:C="urn:ietf:params:xml:ns:caldav">
|
<C:calendar-data />
|
||||||
<D:prop>
|
</D:prop>
|
||||||
<D:getetag/>
|
<C:filter>
|
||||||
<C:calendar-data />
|
<C:comp-filter name="VCALENDAR">
|
||||||
</D:prop>
|
<C:comp-filter name="VTODO">
|
||||||
<C:filter>
|
<C:prop-filter name="LAST-MODIFIED">
|
||||||
<C:comp-filter name="VCALENDAR">
|
<C:time-range start="20210220T000000Z"
|
||||||
<C:comp-filter name="VTODO">
|
end="20260105T000000Z"/>
|
||||||
<C:prop-filter name="LAST-MODIFIED">
|
</C:prop-filter>
|
||||||
<C:time-range start="20210220T000000Z"
|
</C:comp-filter>
|
||||||
end="20260105T000000Z"/>
|
</C:comp-filter>
|
||||||
</C:prop-filter>
|
</C:filter>
|
||||||
</C:comp-filter>
|
</C:calendar-query>
|
||||||
</C:comp-filter>
|
"#;
|
||||||
</C:filter>
|
|
||||||
</C:calendar-query>
|
#[tokio::test]
|
||||||
"#;
|
async fn test_client() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
#[tokio::test]
|
|
||||||
async fn test_client() {
|
let mut client = Client::new(URL, USERNAME, PASSWORD).unwrap();
|
||||||
let _ = env_logger::builder().is_test(true).try_init();
|
let calendars = client.get_calendars().await.unwrap();
|
||||||
|
|
||||||
let mut client = Client::new(URL, USERNAME, PASSWORD).unwrap();
|
println!("Calendars:");
|
||||||
let calendars = client.get_calendars().await.unwrap();
|
let _ = calendars.iter()
|
||||||
|
.map(|cal| println!(" {}\t{}", cal.name(), cal.url().as_str()))
|
||||||
println!("Calendars:");
|
.collect::<()>();
|
||||||
calendars.iter()
|
|
||||||
.map(|cal| println!(" {}\t{}", cal.name(), cal.url().as_str()))
|
let _ = client.get_tasks(&calendars[3].url()).await;
|
||||||
.collect::<()>();
|
}
|
||||||
|
|
||||||
client.get_tasks(&calendars[3].url()).await;
|
#[tokio::test]
|
||||||
}
|
async fn profind() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
#[tokio::test]
|
|
||||||
async fn profind() {
|
let url: Url = EXAMPLE_TASK_URL.parse().unwrap();
|
||||||
let _ = env_logger::builder().is_test(true).try_init();
|
|
||||||
|
let method = Method::from_bytes(b"PROPFIND")
|
||||||
let url: Url = EXAMPLE_TASK_URL.parse().unwrap();
|
.expect("cannot create PROPFIND method.");
|
||||||
|
|
||||||
let method = Method::from_bytes(b"PROPFIND")
|
let res = reqwest::Client::new()
|
||||||
.expect("cannot create PROPFIND method.");
|
.request(method, url.as_str())
|
||||||
|
.header("Depth", 0)
|
||||||
let res = reqwest::Client::new()
|
.header(CONTENT_TYPE, "application/xml")
|
||||||
.request(method, url.as_str())
|
.basic_auth(USERNAME, Some(PASSWORD))
|
||||||
.header("Depth", 0)
|
//.body(body)
|
||||||
.header(CONTENT_TYPE, "application/xml")
|
.send()
|
||||||
.basic_auth(USERNAME, Some(PASSWORD))
|
.await
|
||||||
//.body(body)
|
.unwrap();
|
||||||
.send()
|
|
||||||
.await
|
println!("{:?}", res.text().await);
|
||||||
.unwrap();
|
}
|
||||||
|
|
||||||
println!("{:?}", res.text().await);
|
#[tokio::test]
|
||||||
}
|
async fn last_modified() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
#[tokio::test]
|
|
||||||
async fn last_modified() {
|
let url: Url = EXAMPLE_CALENDAR_URL.parse().unwrap();
|
||||||
let _ = env_logger::builder().is_test(true).try_init();
|
|
||||||
|
let method = Method::from_bytes(b"REPORT")
|
||||||
let url: Url = EXAMPLE_CALENDAR_URL.parse().unwrap();
|
.expect("cannot create REPORT method.");
|
||||||
|
|
||||||
let method = Method::from_bytes(b"REPORT")
|
let res = reqwest::Client::new()
|
||||||
.expect("cannot create REPORT method.");
|
.request(method, url.as_str())
|
||||||
|
.header("Depth", 1)
|
||||||
let res = reqwest::Client::new()
|
.header(CONTENT_TYPE, "application/xml")
|
||||||
.request(method, url.as_str())
|
.basic_auth(USERNAME, Some(PASSWORD))
|
||||||
.header("Depth", 1)
|
.body(EXAMPLE_TASKS_BODY_LAST_MODIFIED)
|
||||||
.header(CONTENT_TYPE, "application/xml")
|
.send()
|
||||||
.basic_auth(USERNAME, Some(PASSWORD))
|
.await
|
||||||
.body(EXAMPLE_TASKS_BODY_LAST_MODIFIED)
|
.unwrap();
|
||||||
.send()
|
|
||||||
.await
|
let el: Element = res.text().await.unwrap().parse().unwrap();
|
||||||
.unwrap();
|
my_tasks::utils::print_xml(&el);
|
||||||
|
}
|
||||||
let el: Element = res.text().await.unwrap().parse().unwrap();
|
|
||||||
my_tasks::utils::print_xml(&el);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue