From 0c76f0c9727a512475e29b5d099b5b7188f72052 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 3 Jan 2020 23:32:44 +0100 Subject: Move Client out of the api objects. Also make constructor functions in the zotapi namespace. --- tests/zotapi.rs | 60 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'tests') 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(); } -- cgit v1.2.3