Skip to content

Commit

Permalink
test(defaults): make test easier to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
gibfahn committed Jan 31, 2025
1 parent 554a715 commit 2a097cf
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions tests/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
#![cfg(target_os = "macos")]

use color_eyre::Result;
use duct::cmd;
use duct::Expression;
use predicates::prelude::*;
use test_log::test;
use testutils::ensure_eq;
use testutils::AssertCmdExt;
use tracing::debug;
use tracing::info;
use tracing::trace;
use up::cmd;
use up::exec::cmd;
use up::exec::UpDuct;

/**
Expand Down Expand Up @@ -312,10 +314,11 @@ fn test_defaults_write_local() -> Result<()> {

info!("Testing default {name}: {test_case:#?}");

let defaults_key = format!("defaults_write_local_{name}");

{
debug!("Writing original value for {name}");
debug!("Writing original value for {name}: {orig_defaults_set_value}");

let defaults_key = format!("defaults_write_local_{name}");
let mut args = vec!["write", &domain, &defaults_key];

let defaults_type_arg;
Expand All @@ -335,14 +338,12 @@ fn test_defaults_write_local() -> Result<()> {
}

{
debug!("Checking we agree with `defaults` about the original value.");
debug!(
"Checking we agree with `defaults` about the original value: {orig_up_check_value}"
);
let mut cmd = testutils::crate_binary_cmd("up", &temp_dir)?;
cmd.args([
"defaults",
"read",
&domain,
&format!("defaults_write_local_{name}"),
]);
cmd.args(["defaults", "read", &domain, &defaults_key]);
trace!("Running: {cmd:?}");
cmd.assert()
.eprint_stdout_stderr()
.try_success()?
Expand All @@ -353,7 +354,6 @@ fn test_defaults_write_local() -> Result<()> {
debug!("Setting the key to the new value ourselves:");
let mut cmd = testutils::crate_binary_cmd("up", &temp_dir)?;

let defaults_key = format!("defaults_write_local_{name}");
cmd.args(["defaults", "write", &domain, &defaults_key, up_set_value]);
cmd.assert()
.eprint_stdout_stderr()
Expand All @@ -365,14 +365,9 @@ fn test_defaults_write_local() -> Result<()> {

{
debug!("Checking that defaults agrees with the new value:");
let new_default = cmd!(
"defaults",
"read",
&domain,
&format!("defaults_write_local_{name}")
)
.read()
.unwrap();
let new_default = cmd!("defaults", "read", &domain, &defaults_key)
.read()
.unwrap();
ensure_eq!(*defaults_check_value, new_default);
}
}
Expand Down

0 comments on commit 2a097cf

Please sign in to comment.