From f38b1cf6c5c37ea41d720a76dc928c25e7437546 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 2 May 2020 12:11:57 +0200 Subject: xchan: update internal api and parse results into struct. --- tests/zotapi.rs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/zotapi.rs b/tests/zotapi.rs index cd127ac..ba279a4 100644 --- a/tests/zotapi.rs +++ b/tests/zotapi.rs @@ -196,10 +196,44 @@ fn upload_item_with_two_files() { m.assert(); } +const EMPTY_XCHAN: &str = r#"{ + "hash": "", + "guid": "", + "guid_sig": "", + "pubkey": "", + "photo_mimetype": "", + "photo_l": "", + "photo_m": "", + "photo_s": "", + "addr": "", + "url": "", + "connurl": "", + "follow": "", + "connpage": "", + "name": "", + "network": "", + "instance_url": "", + "flags": 0, + "photo_date": "", + "name_date": "", + "hidden": 0, + "orphan": 0, + "censored": 0, + "selfcensored": 0, + "system": 0, + "pubforum": 0, + "deleted": 0 +}"#; + #[test] fn fetch_xchan_by_address() { - let m = default_mock("GET", "/api/z/1.0/xchan?address=test%40test.com"); - let _res = zotapi::xchan() + let m = mock_with_authorization("GET", "/api/z/1.0/xchan?address=test%40test.com") + .with_status(200) + .with_header("content-type", "application/json") + .with_body(&EMPTY_XCHAN) + .create(); + + let _res = zotapi::XChan::z() .by_address("test@test.com") .fetch(&client()) .unwrap(); @@ -209,8 +243,13 @@ fn fetch_xchan_by_address() { #[test] fn fetch_xchan_by_hash() { - let m = default_mock("GET", "/api/z/1.0/xchan?hash=baffebaff"); - let _res = zotapi::xchan() + let m = mock_with_authorization("GET", "/api/z/1.0/xchan?hash=baffebaff") + .with_status(200) + .with_header("content-type", "application/json") + .with_body(&EMPTY_XCHAN) + .create(); + + let _res = zotapi::XChan::z() .by_hash("baffebaff") .fetch(&client()) .unwrap(); @@ -220,8 +259,13 @@ fn fetch_xchan_by_hash() { #[test] fn fetch_xchan_by_guid() { - let m = default_mock("GET", "/api/z/1.0/xchan?guid=baffebaff-baff-baff"); - let _res = zotapi::xchan() + let m = mock_with_authorization("GET", "/api/z/1.0/xchan?guid=baffebaff-baff-baff") + .with_status(200) + .with_header("content-type", "application/json") + .with_body(&EMPTY_XCHAN) + .create(); + + let _res = zotapi::XChan::z() .by_guid("baffebaff-baff-baff") .fetch(&client()) .unwrap(); -- cgit v1.2.3