mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
date: bugfix test_date_for_no_permission_file (#4544)
This commit is contained in:
parent
af58532d8a
commit
d8f1f1c16c
1 changed files with 21 additions and 0 deletions
|
@ -282,6 +282,27 @@ fn test_date_for_invalid_file() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_date_for_no_permission_file() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
const FILE: &str = "file-no-perm-1";
|
||||
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let file = std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.open(at.plus(FILE))
|
||||
.unwrap();
|
||||
file.set_permissions(std::fs::Permissions::from_mode(0o222))
|
||||
.unwrap();
|
||||
let result = ucmd.arg("--file").arg(FILE).fails();
|
||||
result.no_stdout();
|
||||
assert_eq!(
|
||||
result.stderr_str().trim(),
|
||||
format!("date: {FILE}: Permission denied")
|
||||
);
|
||||
}
|
||||
|
||||
fn test_date_for_dir_as_file() {
|
||||
let result = new_ucmd!().arg("--file").arg("/").fails();
|
||||
result.no_stdout();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue