-
Notifications
You must be signed in to change notification settings - Fork 3
/
client.rs
63 lines (54 loc) · 1.32 KB
/
client.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
extern crate hyper;
extern crate hyperdav;
extern crate url;
extern crate uuid;
use hyperdav::webdav::Client;
use url::Url;
const OWNCLOUD_URL: &'static str = "https://test:[email protected]/remote.php/webdav/";
macro_rules! url {
($e:expr) => (Url::parse(&format!("{}{}", OWNCLOUD_URL, $e)).unwrap());
}
macro_rules! random_url {
() => (url!(uuid::Uuid::new_v4()));
}
#[test]
fn get() {
let client = Client::new();
let url = random_url!();
let mut f = std::io::empty();
client.put(&mut f, url.clone()).unwrap();
client.get(url).unwrap();
}
#[test]
fn put() {
let client = Client::new();
let mut f = std::io::empty();
client.put(&mut f, random_url!()).unwrap();
}
#[test]
fn mkdir() {
let client = Client::new();
client.mkdir(random_url!()).unwrap();
}
#[test]
fn mv() {
let client = Client::new();
let from = random_url!();
let to = random_url!();
client.mkdir(from.clone()).unwrap();
client.mv(from, to).unwrap();
}
#[test]
fn ls() {
let client = Client::new();
let folder_url = random_url!();
client.mkdir(folder_url.clone()).unwrap();
let res = client.ls(OWNCLOUD_URL).unwrap();
let mut found = false;
for item in res {
if item.href == format!("{}/", folder_url.path()) {
found = true;
}
}
assert!(found);
}