aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/zotapi.rs56
1 files changed, 50 insertions, 6 deletions
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();