From 8294f640abc38611007cdc2697e5117b6c1663b9 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 19 Nov 2018 00:26:38 +0100 Subject: Begin multipart/form-data upload support. --- tests/zotapi.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/zotapi.rs b/tests/zotapi.rs index 3f889c5..37979fd 100644 --- a/tests/zotapi.rs +++ b/tests/zotapi.rs @@ -101,6 +101,26 @@ fn create_new_post_with_title() { m.assert(); } +#[test] +fn upload_item_with_media_file() { + let m = mock("POST", "/api/z/1.0/item/update") + .match_header("authorization", Matcher::Regex(r"Basic \w+".into())) + .match_header("content-type", Matcher::Regex("^multipart/form-data; boundary=.+$".into())) + .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") + .file("testfile.jpg") + .create(); + + m.assert(); +} + #[test] fn fetch_xchan_by_address() { let m = mock("GET", "/api/z/1.0/xchan?address=test%40test.com") -- cgit v1.2.3