diff options
Diffstat (limited to 'tests/zotapi.rs')
-rw-r--r-- | tests/zotapi.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/zotapi.rs b/tests/zotapi.rs index 0437313..49dde02 100644 --- a/tests/zotapi.rs +++ b/tests/zotapi.rs @@ -79,3 +79,24 @@ fn create_new_post() { m.assert(); } + +#[test] +fn create_new_post_with_title() { + // Note this regex is not as good as it could be. But since the rust regex crate + // don't support back references it's the best we can do and not care about the + // oder of the entries. + let expected_body = Matcher::Regex(r"(title=A\+title&?|body=This\+is\+a\+test&?){2}".into()); + + let m = mock("POST", "/api/z/1.0/item/update") + .match_header("Authorization", Matcher::Regex(r"Basic \w+".into())) + .match_body(expected_body) + .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.item().title("A title").body("This is a test").create(); + + m.assert(); +} |