aboutsummaryrefslogtreecommitdiffstats
path: root/tests/upload_files.rs
diff options
context:
space:
mode:
authorJohannes May <johannes@may-se.de>2022-03-13 17:54:42 +0000
committerJohannes May <johannes@may-se.de>2022-03-13 18:17:10 +0000
commit6a6baec9ab16e004b4163af3012a949412df1148 (patch)
tree816928ce8bb0c8a13485e24cfad83a554dc41f8b /tests/upload_files.rs
parentAllow to set the accept input attribute to arbitrary values (diff)
downloadminiserve-6a6baec9ab16e004b4163af3012a949412df1148.tar.gz
miniserve-6a6baec9ab16e004b4163af3012a949412df1148.zip
Add test cases for the media-type parameters
Diffstat (limited to 'tests/upload_files.rs')
-rw-r--r--tests/upload_files.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/upload_files.rs b/tests/upload_files.rs
index 5e764ba..71fcbc4 100644
--- a/tests/upload_files.rs
+++ b/tests/upload_files.rs
@@ -167,3 +167,23 @@ fn upload_to_symlink_directory(
Ok(())
}
+
+/// Test setting the HTML accept attribute using -m and -M.
+#[rstest]
+#[case(server(&["-u"]), None)]
+#[case(server(&["-u", "-m", "image"]), Some("image/*"))]
+#[case(server(&["-u", "-m", "image", "-m", "audio", "-m", "video"]), Some("image/*,audio/*,video/*"))]
+#[case(server(&["-u", "-m", "audio", "-m", "image", "-m", "video"]), Some("audio/*,image/*,video/*"))]
+#[case(server(&["-u", "-M", "test_value"]), Some("test_value"))]
+fn set_media_type(
+ #[case] server: TestServer,
+ #[case] expected_accept_value: Option<&str>,
+) -> Result<(), Error> {
+ let body = reqwest::blocking::get(server.url())?.error_for_status()?;
+ let parsed = Document::from_read(body)?;
+
+ let input = parsed.find(Attr("id", "file-input")).next().unwrap();
+ assert_eq!(input.attr("accept"), expected_accept_value);
+
+ Ok(())
+}