Skip to content

Commit

Permalink
Fix tests to use tmp file
Browse files Browse the repository at this point in the history
  • Loading branch information
tbsklg committed Aug 23, 2024
1 parent 0acaa4b commit 06d87d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 11 additions & 4 deletions cli-client/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use predicates::prelude::*;
use std::process::Command;

#[test]
fn missing_subcommand() -> Result<(), Box<dyn std::error::Error>> {
fn it_should_recognize_missing_subcommand() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("strikes")?;

cmd.arg("guenther");
Expand All @@ -17,13 +17,20 @@ fn missing_subcommand() -> Result<(), Box<dyn std::error::Error>> {

#[test]
fn it_should_add_strike() -> Result<(), Box<dyn std::error::Error>> {
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();
Expand Down
3 changes: 0 additions & 3 deletions cli-client/tests/fixtures/db.json

This file was deleted.

0 comments on commit 06d87d0

Please sign in to comment.