diff --git a/tests/data/content/symlink.gmi b/tests/data/content/symlink.gmi new file mode 120000 index 0000000..1319e38 --- /dev/null +++ b/tests/data/content/symlink.gmi @@ -0,0 +1 @@ +index.gmi \ No newline at end of file diff --git a/tests/data/content/symlinked_dir b/tests/data/content/symlinked_dir new file mode 120000 index 0000000..9450d37 --- /dev/null +++ b/tests/data/content/symlinked_dir @@ -0,0 +1 @@ +../symlinked_dir/ \ No newline at end of file diff --git a/tests/data/symlinked_dir/file.gmi b/tests/data/symlinked_dir/file.gmi new file mode 100644 index 0000000..78e13b6 --- /dev/null +++ b/tests/data/symlinked_dir/file.gmi @@ -0,0 +1 @@ +Hello from the symlink'ed directory! diff --git a/tests/tests.rs b/tests/tests.rs index 069d79e..5be4b8f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -145,6 +145,66 @@ fn index_page() { ); } +#[test] +/// - symlinked files are followed correctly +fn symlink_page() { + let page = get( + &["--addr", "[::]:1986"], + addr(1986), + "gemini://localhost/symlink.gmi", + ) + .expect("could not get page"); + + assert_eq!( + page.header, + Header { + status: Status::Success, + meta: "text/gemini".to_string(), + } + ); + + assert_eq!( + page.body, + Some( + std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/data/content/index.gmi" + )) + .unwrap() + ) + ); +} + +#[test] +/// - symlinked directories are followed correctly +fn symlink_directory() { + let page = get( + &["--addr", "[::]:1987"], + addr(1987), + "gemini://localhost/symlinked_dir/file.gmi", + ) + .expect("could not get page"); + + assert_eq!( + page.header, + Header { + status: Status::Success, + meta: "text/gemini".to_string(), + } + ); + + assert_eq!( + page.body, + Some( + std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/data/symlinked_dir/file.gmi" + )) + .unwrap() + ) + ); +} + #[test] /// - the `--addr` configuration works /// - MIME media types can be set in the configuration file