aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-12-16 23:17:26 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-12-16 23:17:26 +0100
commit30e648412c33df5f26a951d5f11b9d602a0da149 (patch)
treeef9f3361a591abdd7e0ffbc5d4aec5e22648ac9e
parente4e75aa8c85b15b91ef57b4288e620bf3d906500 (diff)
downloadrust-zotapi-30e648412c33df5f26a951d5f11b9d602a0da149.tar.gz
rust-zotapi-30e648412c33df5f26a951d5f11b9d602a0da149.tar.bz2
rust-zotapi-30e648412c33df5f26a951d5f11b9d602a0da149.zip
Add test for uploading two files.
-rw-r--r--tests/zotapi.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/zotapi.rs b/tests/zotapi.rs
index 3105240..93c9795 100644
--- a/tests/zotapi.rs
+++ b/tests/zotapi.rs
@@ -134,6 +134,43 @@ fn upload_item_with_media_file() {
}
#[test]
+fn upload_item_with_two_files() {
+ 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()))
+ .match_body(Matcher::Regex(
+ "--.+\r\n".to_owned() +
+ "Content-Disposition: form-data; name=\"body\"\r\n" +
+ "\r\nThis is a test\r\n" +
+ "--.+\r\n" +
+ "Content-Disposition: form-data; name=\"title\"\r\n" +
+ "\r\nA title\r\n" +
+ "--.+\r\n" +
+ "Content-Disposition: form-data; name=\"files\"; filename=\"testfile.txt\"\r\n" +
+ "Content-Type: text/plain\r\n" +
+ "\r\ntestfile contents\n" +
+ "\r\n--.+\r\n" +
+ "Content-Disposition: form-data; name=\"files\"; filename=\"testfile.txt\"\r\n" +
+ "Content-Type: text/plain\r\n" +
+ "\r\ntestfile contents\n" +
+ "\r\n--.+--\r\n"))
+ .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("tests/fixtures/testfile.txt")
+ .file("tests/fixtures/testfile.txt")
+ .create();
+
+ m.assert();
+}
+
+#[test]
fn fetch_xchan_by_address() {
let m = mock("GET", "/api/z/1.0/xchan?address=test%40test.com")
.match_header("Authorization", Matcher::Regex(r"Basic \w+".into()))