Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
unrenamed committed Aug 29, 2023
1 parent ca6589a commit e805060
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,46 @@ mod tests {
use clap::CommandFactory;
Cli::command().debug_assert()
}

use assert_cmd::Command;
use assert_fs::fixture::TempDir;

#[test]
fn image_save_success() {
let output_dir = TempDir::new().unwrap();
let file_path = format!("{}/maze.png", output_dir.path().display());
let expected = format!("Maze was successfully saved as an image: {}\n", &file_path);

let mut cmd = Command::cargo_bin(assert_cmd::crate_name!()).unwrap();
cmd.args(["generate", "image", "--output-path", &file_path])
.assert()
.success()
.stdout(expected);
}

#[test]
fn ascii_save_success() {
let output_dir = TempDir::new().unwrap();
let file_path = format!("{}/maze.txt", output_dir.path().display());
let expected = format!("Maze was successfully written to a file: {}\n", file_path);

let mut cmd = Command::cargo_bin(assert_cmd::crate_name!()).unwrap();
cmd.args(["generate", "ascii", "--output-path", &file_path])
.assert()
.success()
.stdout(expected);
}

#[test]
fn game_map_save_success() {
let output_dir = TempDir::new().unwrap();
let file_path = format!("{}/maze.txt", output_dir.path().display());
let expected = format!("Maze was successfully written to a file: {}\n", file_path);

let mut cmd = Command::cargo_bin(assert_cmd::crate_name!()).unwrap();
cmd.args(["generate", "game-map", "--output-path", &file_path])
.assert()
.success()
.stdout(expected);
}
}

0 comments on commit e805060

Please sign in to comment.