add tests for directory listing

This commit is contained in:
Johann150 2021-11-07 15:24:01 +01:00
parent d10c512253
commit 010d020ba1
No known key found for this signature in database
GPG key ID: 9EE6577A2A06F8F1
10 changed files with 51 additions and 0 deletions

View file

View file

@ -0,0 +1 @@
This is a directory listing

View file

View file

View file

View file

View file

0
tests/data/dirlist/a Normal file
View file

0
tests/data/dirlist/b Normal file
View file

View file

@ -669,3 +669,53 @@ mod multicert {
server.stop().unwrap();
}
}
mod directory_listing {
use super::*;
#[test]
/// - shows directory listing when enabled
/// - shows directory listing preamble correctly
/// - encodes link URLs correctly
fn with_preamble() {
let page = get(
&["--addr", "[::]:1990", "--content", "dirlist-preamble"],
addr(1990),
"gemini://localhost/",
)
.expect("could not get page");
assert_eq!(
page.header,
Header {
status: Status::Success,
meta: "text/gemini".into(),
}
);
assert_eq!(
page.body,
Some("This is a directory listing\n=> %23yeah #yeah\n=> a\n=> b\n=> huh%3F huh?\n=> wao%20spaces wao spaces\n".into())
);
}
#[test]
fn empty_preamble() {
let page = get(
&["--addr", "[::]:1991", "--content", "dirlist"],
addr(1991),
"gemini://localhost/",
)
.expect("could not get page");
assert_eq!(
page.header,
Header {
status: Status::Success,
meta: "text/gemini".into(),
}
);
assert_eq!(page.body, Some("=> a\n=> b\n".into()),);
}
}