Skip to content

Commit

Permalink
test(defaults): switch to a default that is defined everywhere
Browse files Browse the repository at this point in the history
Turns out some machines don't have the FXPreferredViewStyle default set,
so pick another one that is hopefully unavoidable.
  • Loading branch information
gibfahn committed Dec 24, 2023
1 parent b09a38f commit c05bc7a
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions tests/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,39 +55,24 @@ fn test_defaults_read_global() {
fn test_defaults_read_local() {
let temp_dir = testutils::temp_dir("up", testutils::function_path!()).unwrap();

// Four-letter codes for view modes: `icnv`, `clmv`, `glyv`, `Nlsv`
let mut expected_value = cmd!(
"defaults",
"read",
"com.apple.finder",
"FXPreferredViewStyle"
)
.read()
.unwrap();
// Dock region, e.g. 'GB'
let mut expected_value = cmd!("defaults", "read", "com.apple.dock", "region")
.read()
.unwrap();
expected_value.push('\n');

// Reading a normal value should have the same output as the defaults command (but yaml not
// defaults own format).
{
let mut cmd = testutils::test_binary_cmd("up", &temp_dir);
cmd.args([
"defaults",
"read",
"com.apple.finder",
"FXPreferredViewStyle",
]);
cmd.args(["defaults", "read", "com.apple.dock", "region"]);
cmd.assert().success().stdout(expected_value.clone());
}

// A .plist extension should be allowed too.
{
let mut cmd = testutils::test_binary_cmd("up", &temp_dir);
cmd.args([
"defaults",
"read",
"com.apple.finder.plist",
"FXPreferredViewStyle",
]);
cmd.args(["defaults", "read", "com.apple.dock.plist", "region"]);
cmd.assert().success().stdout(expected_value.clone());
}

Expand All @@ -98,10 +83,10 @@ fn test_defaults_read_local() {
"defaults",
"read",
&format!(
"{}/Library/Preferences/com.apple.finder.plist",
"{}/Library/Preferences/com.apple.dock.plist",
dirs::home_dir().unwrap().display()
),
"FXPreferredViewStyle",
"region",
]);
cmd.assert().success().stdout(expected_value);
}
Expand Down

0 comments on commit c05bc7a

Please sign in to comment.