Browse Source

[minor] Examples have different data folders

master
daladim 4 years ago
parent
commit
511f2123e6
  1. 4
      examples/provider-sync.rs
  2. 6
      examples/shared.rs
  3. 3
      examples/toggle-completions.rs

4
examples/provider-sync.rs

@ -17,6 +17,8 @@ mod shared;
use shared::initial_sync;
use shared::{URL, USERNAME, EXAMPLE_EXISTING_CALENDAR_URL, EXAMPLE_CREATED_CALENDAR_URL};
const CACHE_FOLDER: &str = "test_cache/provider_sync";
#[tokio::main]
async fn main() {
@ -33,7 +35,7 @@ async fn main() {
println!(" * EXAMPLE_CREATED_CALENDAR_URL = {}", EXAMPLE_CREATED_CALENDAR_URL);
pause();
let mut provider = initial_sync().await;
let mut provider = initial_sync(CACHE_FOLDER).await;
add_items_and_sync_again(&mut provider).await;
}

6
examples/shared.rs

@ -14,16 +14,14 @@ pub const PASSWORD: &str = "secret_password";
pub const EXAMPLE_EXISTING_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/";
pub const EXAMPLE_CREATED_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/";
const CACHE_FOLDER: &str = "test_cache/provider_sync";
fn main() {
panic!("This file is not supposed to be executed");
}
/// Initializes a Provider, and run an initial sync from the server
pub async fn initial_sync() -> CalDavProvider {
let cache_path = Path::new(CACHE_FOLDER);
pub async fn initial_sync(cache_folder: &str) -> CalDavProvider {
let cache_path = Path::new(cache_folder);
let client = Client::new(URL, USERNAME, PASSWORD).unwrap();
let cache = match Cache::from_folder(&cache_path) {

3
examples/toggle-completions.rs

@ -14,6 +14,7 @@ mod shared;
use shared::initial_sync;
use shared::{URL, USERNAME};
const CACHE_FOLDER: &str = "test_cache/toggle_completion";
#[tokio::main]
async fn main() {
@ -28,7 +29,7 @@ async fn main() {
println!(" * USERNAME = {}", USERNAME);
pause();
let mut provider = initial_sync().await;
let mut provider = initial_sync(CACHE_FOLDER).await;
toggle_all_tasks_and_sync_again(&mut provider).await.unwrap();
}

Loading…
Cancel
Save