From 1ba083af3576d20b5c1fc1c6ebacefd91ceb6636 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 4 Jan 2020 13:15:00 +0100 Subject: abconfig: reorg + parse result into struct. --- tests/zotapi.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/zotapi.rs b/tests/zotapi.rs index 1621af1..70a9564 100644 --- a/tests/zotapi.rs +++ b/tests/zotapi.rs @@ -240,9 +240,38 @@ fn fetch_connections() { #[test] fn fetch_abconfig() { - let m = default_mock("GET", "/api/z/1.0/abconfig"); - let _res = zotapi::abconfig().fetch(&client()).unwrap(); + let data = r#" + [ + { + "id": 666, + "chan": 42, + "xchan": "xchanhash1", + "cat": "some_other_cat", + "k": "key1", + "v": "value1" + }, + { + "id": 667, + "chan": 44, + "xchan": "xchanhash2", + "cat": "some_cat", + "k": "key2", + "v": "value2" + } + + ]"#; + + let m = mock_with_authorization("GET", "/api/z/1.0/abconfig") + .with_status(200) + .with_body(&data) + .create(); + + let res = zotapi::abconfig::fetch(&client()).unwrap(); m.assert(); + + assert_eq!(res.len(), 2); + assert_eq!(res[0].id, 666); + assert_eq!(res[1].k, "key2"); } #[test] -- cgit v1.2.3