aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-08-19 20:29:14 +0200
committerHarald Eilertsen <haraldei@anduin.net>2018-08-19 20:29:14 +0200
commit7e1ee802f03208c2a50ba73b7b9f8b841bddb54a (patch)
tree9790db1fd2da825be00d1348b9770d61ba8fc787 /tests
parent225478bb8c19705ab865f209fe692eb426ea1e51 (diff)
downloadrust-zotapi-7e1ee802f03208c2a50ba73b7b9f8b841bddb54a.tar.gz
rust-zotapi-7e1ee802f03208c2a50ba73b7b9f8b841bddb54a.tar.bz2
rust-zotapi-7e1ee802f03208c2a50ba73b7b9f8b841bddb54a.zip
First attempt at creating posts.
Diffstat (limited to 'tests')
-rw-r--r--tests/zotapi.rs16
1 files changed, 16 insertions, 0 deletions
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();
+}