Skip to content

Commit

Permalink
test(libmake): ✅ add new test for ascii_macros.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed May 15, 2024
1 parent 9bf7069 commit f943c7a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
22 changes: 22 additions & 0 deletions tests/test_ascii_macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#[cfg(test)]
mod tests {
use libmake::macro_ascii;

#[test]
fn test_macro_ascii_success() {
let art = macro_ascii!("Hi");
assert_eq!(art, " _ _ _ \n | | | | (_)\n | |_| | | |\n | _ | | |\n |_| |_| |_|\n \n");
}

#[test]
#[should_panic(expected = "Failed to generate ASCII art: Failed to convert text to ASCII art")]
fn test_macro_ascii_empty_input() {
let _art = macro_ascii!("");
}

#[test]
#[should_panic(expected = "Failed to generate ASCII art: Failed to convert text to ASCII art")]
fn test_macro_ascii_invalid_input() {
let _art = macro_ascii!("🦀");
}
}
15 changes: 3 additions & 12 deletions tests/data/test_yaml.rs → tests/test_yaml.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
#[cfg(test)]
mod tests {
use libmake::generators::yaml::generate_from_yaml;
use std::io::{self, Write};
use std::io::Write;
use std::fs::File;
use tempfile::tempdir;

#[test]
fn test_generate_from_yaml_success() {
let dir = tempdir().unwrap();
let file_path = "./tests/data/mylibrary.yaml";

let yaml_data = r#"
output: test_output_dir
"#;

let mut file = File::create(&file_path).unwrap();
file.write_all(yaml_data.as_bytes()).unwrap();

let result = generate_from_yaml(file_path.to_str().unwrap());
assert!(result.is_ok());
generate_from_yaml(file_path).unwrap();
assert_eq!(true, true);
}

#[test]
Expand Down

0 comments on commit f943c7a

Please sign in to comment.