aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-05-02 12:11:57 +0200
committerYour Name <you@example.com>2020-05-02 12:11:57 +0200
commitf38b1cf6c5c37ea41d720a76dc928c25e7437546 (patch)
treeb57ee11eaecee214d30544c4b62ebd61a10158c0 /tests
parent73f4ff61c4d3dc8c70d048c71bb23651c460c107 (diff)
downloadrust-zotapi-f38b1cf6c5c37ea41d720a76dc928c25e7437546.tar.gz
rust-zotapi-f38b1cf6c5c37ea41d720a76dc928c25e7437546.tar.bz2
rust-zotapi-f38b1cf6c5c37ea41d720a76dc928c25e7437546.zip
xchan: update internal api and parse results into struct.
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();