-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ryan Brue <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::{ | ||
env::temp_dir, | ||
fs::{create_dir_all, remove_dir_all, File}, | ||
io::Write, | ||
}; | ||
|
||
use crate::ConsoleArgs; | ||
|
||
#[test] | ||
fn site_warn_without_index() -> anyhow::Result<()> { | ||
let temp_dir = temp_dir(); | ||
// Perform test with catch | ||
let res: anyhow::Result<()> = (|| { | ||
create_dir_all(&temp_dir.join("target/nested"))?; | ||
let mut djot_file_1 = File::create(&temp_dir.join("target/nested/example.dj"))?; | ||
write!( | ||
djot_file_1, | ||
"# Hey everyone!\n\nThis is an example djot file!\n\n> Hey what's up" | ||
)?; | ||
djot_file_1.flush()?; | ||
|
||
let mut djot_file_2 = File::create(&temp_dir.join("target/example2.dj"))?; | ||
write!( | ||
djot_file_2, | ||
"# Hey everyone!\n\nThis is another example djot file!\n\n> Hey what's up!!" | ||
)?; | ||
djot_file_2.flush()?; | ||
|
||
let args = ConsoleArgs { | ||
target_path: temp_dir.join("target"), | ||
output_path: Some(temp_dir.join("output")), | ||
clean: false, | ||
no_warn: true, | ||
}; | ||
crate::run_program(args)?; | ||
Ok(()) | ||
})(); | ||
let _ = remove_dir_all(&temp_dir); | ||
match res { | ||
Ok(()) => { | ||
// This should have errored out | ||
Err(anyhow::anyhow!("This should have errored out")) | ||
} | ||
Err(e) => { | ||
// Ok(()) | ||
if e.to_string() == "index.{dj|djot} not found! consider creating one in the base target directory as the default page.".to_string() { | ||
Ok(()) | ||
} else { | ||
Err(e) | ||
} | ||
} | ||
} | ||
} |