From 7e1ee802f03208c2a50ba73b7b9f8b841bddb54a Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 19 Aug 2018 20:29:14 +0200 Subject: First attempt at creating posts. --- tests/zotapi.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/zotapi.rs b/tests/zotapi.rs index 90f5298..f8991f7 100644 --- a/tests/zotapi.rs +++ b/tests/zotapi.rs @@ -63,3 +63,19 @@ fn return_error_if_invalid_auth_provided() { assert!(data.is_err()); assert_eq!(format!("{:?}", data), "Err(Unauthorized)"); } + +#[test] +fn create_new_post() { + let m = mock("POST", "/api/z/1.0/item/update") + .match_header("Authorization", Matcher::Regex(r"Basic \w+".into())) + .match_body("body=This+is+a+test") + .with_status(200) + .with_header("content-type", "application/json") + .with_body("{}") + .create(); + + let z = zotapi::client(&format!("http://{}", mockito::SERVER_ADDRESS), "testuser", "test1234"); + let res = z.create_item("This is a test"); + + m.assert(); +} -- cgit v1.2.3