mirror of
https://github.com/samsonjs/agate.git
synced 2026-03-25 09:05:50 +00:00
add tests for directory listing
This commit is contained in:
parent
d10c512253
commit
010d020ba1
10 changed files with 51 additions and 0 deletions
0
tests/data/dirlist-preamble/#yeah
Normal file
0
tests/data/dirlist-preamble/#yeah
Normal file
1
tests/data/dirlist-preamble/.directory-listing-ok
Normal file
1
tests/data/dirlist-preamble/.directory-listing-ok
Normal file
|
|
@ -0,0 +1 @@
|
|||
This is a directory listing
|
||||
0
tests/data/dirlist-preamble/a
Normal file
0
tests/data/dirlist-preamble/a
Normal file
0
tests/data/dirlist-preamble/b
Normal file
0
tests/data/dirlist-preamble/b
Normal file
0
tests/data/dirlist-preamble/huh?
Normal file
0
tests/data/dirlist-preamble/huh?
Normal file
0
tests/data/dirlist-preamble/wao spaces
Normal file
0
tests/data/dirlist-preamble/wao spaces
Normal file
0
tests/data/dirlist/.directory-listing-ok
Normal file
0
tests/data/dirlist/.directory-listing-ok
Normal file
0
tests/data/dirlist/a
Normal file
0
tests/data/dirlist/a
Normal file
0
tests/data/dirlist/b
Normal file
0
tests/data/dirlist/b
Normal 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()),);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue