aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cli_test.rs42
1 files changed, 24 insertions, 18 deletions
diff --git a/tests/cli_test.rs b/tests/cli_test.rs
index 641d6f7..5c5615a 100644
--- a/tests/cli_test.rs
+++ b/tests/cli_test.rs
@@ -1,5 +1,5 @@
use std::env;
-use std::fs::read_to_string;
+use std::fs::{create_dir_all, read_to_string};
use std::path::PathBuf;
use std::process::Command;
use test_utilities::*;
@@ -19,18 +19,20 @@ impl Drop for TestDir {
#[test]
fn test_basic_generation() {
let test_dir = setup_test_dir();
- let dir_name = test_dir.file_name().unwrap().to_string_lossy();
- let parent = test_dir.parent().unwrap();
- let html_dir = parent.join(format!("{dir_name}_html"));
- let gemini_dir = parent.join(format!("{dir_name}_gemini"));
+ let input_dir = test_dir.join("tezt");
+ let output_dir = test_dir.join("output");
+ let html_dir = output_dir.join("page").join("tezt").join("html");
+ let gemini_dir = output_dir.join("page").join("tezt").join("gemini");
+ create_dir_all(&input_dir).expect("Could not create input directory");
+ create_dir_all(&output_dir).expect("Could not create output directory");
let _cleanup = TestDir {
- paths: vec![test_dir.clone(), html_dir.clone(), gemini_dir.clone()],
+ paths: vec![test_dir.clone()],
};
// Create test input files
create_test_file(
- &test_dir.join("_layout.html"),
+ &input_dir.join("_layout.html"),
"\
<html>
<head><title>{{ title }}</title></head>
@@ -39,18 +41,19 @@ fn test_basic_generation() {
",
);
create_test_file(
- &test_dir.join("test.gmi"),
+ &input_dir.join("test.gmi"),
"\
--- title: Page Is Cool!
# Test
Hello world
",
);
- create_test_file(&test_dir.join("test.png"), "A picture of a cute cat");
+ create_test_file(&input_dir.join("test.png"), "A picture of a cute cat");
// Run the program from the test directory
let status = Command::new(env!("CARGO_BIN_EXE_page"))
- .current_dir(&test_dir)
+ .current_dir(&input_dir)
+ .env("PAGE_OUTPUT_DIRECTORY", &output_dir)
.status()
.expect("Failed to execute command");
@@ -95,29 +98,32 @@ Hello world
#[test]
fn test_missing_layout() {
let test_dir = setup_test_dir();
- let dir_name = test_dir.file_name().unwrap().to_string_lossy();
- let parent = test_dir.parent().unwrap();
- let html_dir = parent.join(format!("{dir_name}_html"));
- let gemini_dir = parent.join(format!("{dir_name}_gemini"));
+ let input_dir = test_dir.join("tezt2");
+ let output_dir = test_dir.join("output");
+ let html_dir = output_dir.join("page").join("tezt2").join("html");
+ let gemini_dir = output_dir.join("page").join("tezt2").join("gemini");
+ create_dir_all(&input_dir).expect("Could not create input directory");
+ create_dir_all(&output_dir).expect("Could not create output directory");
let _cleanup = TestDir {
- paths: vec![test_dir.clone(), html_dir.clone(), gemini_dir.clone()],
+ paths: vec![test_dir.clone()],
};
// Create test input files
create_test_file(
- &test_dir.join("test.gmi"),
+ &input_dir.join("test.gmi"),
"\
--- title: Page Is Cool!
# Test
Hello world
",
);
- create_test_file(&test_dir.join("test.png"), "A picture of a cute cat");
+ create_test_file(&input_dir.join("test.png"), "A picture of a cute cat");
// Run the program from the test directory
let status = Command::new(env!("CARGO_BIN_EXE_page"))
- .current_dir(&test_dir)
+ .current_dir(&input_dir)
+ .env("PAGE_OUTPUT_DIRECTORY", &output_dir)
.status()
.expect("Failed to execute command");