Skip to content

Commit

Permalink
Fix test_has_write_permission temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoheiu committed Nov 4, 2024
1 parent 229737a commit cf78363
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2052,19 +2052,26 @@ mod tests {
fn test_has_write_permission() {
// chmod to 444 and check if it's read-only
let p = std::path::PathBuf::from("./testfiles/permission_test");
let _status = std::process::Command::new("chmod")
let status = std::process::Command::new("/usr/bin/chmod")
.args(["444", "./testfiles/permission_test"])
.status()
.unwrap();
assert!(!has_write_permission(p.as_path()).unwrap());
let _status = std::process::Command::new("chmod")
.status();
if let Ok(status) = status {
if status.success() {
assert!(!has_write_permission(p.as_path()).unwrap());
}
}

let status = std::process::Command::new("/usr/bin/chmod")
.args(["755", "./testfiles/permission_test"])
.status()
.unwrap();
.status();

// Test the home directory, which should pass
let home_dir = dirs::home_dir().unwrap();
assert!(has_write_permission(&home_dir).unwrap());
if let Ok(status) = status {
if status.success() {
let home_dir = dirs::home_dir().unwrap();
assert!(has_write_permission(&home_dir).unwrap());
}
}
}

#[test]
Expand Down

0 comments on commit cf78363

Please sign in to comment.