aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-01-03 23:32:44 +0100
committerHarald Eilertsen <haraldei@anduin.net>2020-01-03 23:32:44 +0100
commit0c76f0c9727a512475e29b5d099b5b7188f72052 (patch)
treed1c2b59458c62116447fa2d885113afe6a5378da /tests
parent5f96d9981a6d041f5c8a464cda10a0dc371060f8 (diff)
downloadrust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.tar.gz
rust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.tar.bz2
rust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.zip
Move Client out of the api objects.
Also make constructor functions in the zotapi namespace.
Diffstat (limited to 'tests')
-rw-r--r--tests/zotapi.rs60
1 files changed, 33 insertions, 27 deletions
diff --git a/tests/zotapi.rs b/tests/zotapi.rs
index 66fe15e..4c0a207 100644
--- a/tests/zotapi.rs
+++ b/tests/zotapi.rs
@@ -74,7 +74,9 @@ fn create_new_post() {
.with_body("{}")
.create();
- let _res = client().item().body("This is a test").create();
+ let _res = zotapi::item()
+ .body("This is a test")
+ .create(&client());
m.assert();
}
@@ -91,11 +93,10 @@ fn create_new_post_with_title() {
.with_body("{}")
.create();
- let _res = client()
- .item()
+ let _res = zotapi::item()
.title("A title")
.body("This is a test")
- .create();
+ .create(&client());
m.assert();
}
@@ -118,11 +119,10 @@ fn create_new_post_limited_to_one_privacy_group() {
.with_body("{}")
.create();
- let _res = client()
- .item()
+ let _res = zotapi::item()
.body("This is a test")
.group_allow("grouphash")
- .create();
+ .create(&client());
//m.assert();
}
@@ -152,12 +152,11 @@ fn upload_item_with_media_file() {
.with_body("{}")
.create();
- let _res = client()
- .item()
+ let _res = zotapi::item()
.title("A title")
.body("This is a test")
.file("tests/fixtures/testfile.txt")
- .create();
+ .create(&client());
m.assert();
}
@@ -191,13 +190,12 @@ fn upload_item_with_two_files() {
.with_body("{}")
.create();
- let _res = client()
- .item()
+ let _res = zotapi::item()
.title("A title")
.body("This is a test")
.file("tests/fixtures/testfile.txt")
.file("tests/fixtures/testfile.txt")
- .create();
+ .create(&client());
m.assert();
}
@@ -205,50 +203,54 @@ fn upload_item_with_two_files() {
#[test]
fn fetch_xchan_by_address() {
let m = default_mock("GET", "/api/z/1.0/xchan?address=test%40test.com");
- let _res = client()
- .xchan()
+ let _res = zotapi::xchan()
.by_address("test@test.com")
- .fetch()
+ .fetch(&client())
.unwrap();
+
m.assert();
}
#[test]
fn fetch_xchan_by_hash() {
let m = default_mock("GET", "/api/z/1.0/xchan?hash=baffebaff");
- let _res = client().xchan().by_hash("baffebaff").fetch().unwrap();
+ let _res = zotapi::xchan()
+ .by_hash("baffebaff")
+ .fetch(&client())
+ .unwrap();
+
m.assert();
}
#[test]
fn fetch_xchan_by_guid() {
let m = default_mock("GET", "/api/z/1.0/xchan?guid=baffebaff-baff-baff");
- let _res = client()
- .xchan()
+ let _res = zotapi::xchan()
.by_guid("baffebaff-baff-baff")
- .fetch()
+ .fetch(&client())
.unwrap();
+
m.assert();
}
#[test]
fn fetch_connections() {
let m = default_mock("GET", "/api/z/1.0/abook");
- let _res = client().abook().fetch().unwrap();
+ let _res = zotapi::abook().fetch(&client()).unwrap();
m.assert();
}
#[test]
fn fetch_abconfig() {
let m = default_mock("GET", "/api/z/1.0/abconfig");
- let _res = client().abconfig().fetch().unwrap();
+ let _res = zotapi::abconfig().fetch(&client()).unwrap();
m.assert();
}
#[test]
fn fetch_privacy_groups() {
let m = default_mock("GET", "/api/z/1.0/group");
- let _res = client().group().fetch().unwrap();
+ let _res = zotapi::group().fetch(&client()).unwrap();
m.assert();
}
@@ -264,7 +266,11 @@ fn fetch_members_of_group_by_group_id() {
.with_body("{}")
.create();
- let _res = client().group_members().by_group_id(42).fetch().unwrap();
+ let _res = zotapi::group_members()
+ .by_group_id(42)
+ .fetch(&client())
+ .unwrap();
+
m.assert();
}
@@ -280,10 +286,10 @@ fn fetch_members_of_group_by_group_name() {
.with_body("{}")
.create();
- let _res = client()
- .group_members()
+ let _res = zotapi::group_members()
.by_group_name("Friends of pain")
- .fetch()
+ .fetch(&client())
.unwrap();
+
m.assert();
}