agate

Simple gemini server for static files
git clone https://github.com/mbrubeck/agate.git
Log | Files | Refs | README

commit 14e15d430a5b3de9f82b9346213c0703d2d63276
parent f890de24f6924467f5ff356bfd230344beea7a28
Author: Johann150 <johann.galle@protonmail.com>
Date:   Sun,  6 Jun 2021 10:49:20 +0200

add tests for symbolically linked files & directories

trying to reproduce issue #60

Diffstat:
Atests/data/content/symlink.gmi | 2++
Atests/data/content/symlinked_dir | 2++
Atests/data/symlinked_dir/file.gmi | 1+
Mtests/tests.rs | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/tests/data/content/symlink.gmi 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 @@ -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 @@ -0,0 +1 @@ +Hello from the symlink'ed directory! diff --git a/tests/tests.rs b/tests/tests.rs @@ -146,6 +146,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 fn meta() {