From 06d87d00e51cd36917d5dcac7d649de443015f95 Mon Sep 17 00:00:00 2001 From: Tobias Klug Date: Fri, 23 Aug 2024 14:42:46 +0200 Subject: [PATCH] Fix tests to use tmp file --- cli-client/tests/cli.rs | 15 +++++++++++---- cli-client/tests/fixtures/db.json | 3 --- 2 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 cli-client/tests/fixtures/db.json diff --git a/cli-client/tests/cli.rs b/cli-client/tests/cli.rs index 8bb5eca..1288fab 100644 --- a/cli-client/tests/cli.rs +++ b/cli-client/tests/cli.rs @@ -4,7 +4,7 @@ use predicates::prelude::*; use std::process::Command; #[test] -fn missing_subcommand() -> Result<(), Box> { +fn it_should_recognize_missing_subcommand() -> Result<(), Box> { let mut cmd = Command::cargo_bin("strikes")?; cmd.arg("guenther"); @@ -17,13 +17,20 @@ fn missing_subcommand() -> Result<(), Box> { #[test] fn it_should_add_strike() -> Result<(), Box> { - let file = assert_fs::NamedTempFile::new("./tests/fixtures/configuration.yaml")?; - file.write_str("{\"local\": {\"db_path\": \"./tests/fixtures/db.json\"}}")?; + let db_file = assert_fs::NamedTempFile::new("./tests/fixtures/db.json")?; + let config_file = assert_fs::NamedTempFile::new("./tests/fixtures/configuration.yaml")?; + config_file.write_str( + format!( + "{{\"local\": {{\"db_path\": \"{}\"}}}}", + db_file.path().to_str().unwrap() + ) + .as_str(), + )?; let mut cmd = Command::cargo_bin("strikes")?; cmd.arg("--config-path") - .arg(file.path()) + .arg(config_file.path()) .arg("strike") .arg("guenther"); cmd.assert().success(); diff --git a/cli-client/tests/fixtures/db.json b/cli-client/tests/fixtures/db.json deleted file mode 100644 index 2347931..0000000 --- a/cli-client/tests/fixtures/db.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "guenther": 6 -} \ No newline at end of file