mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #5168 from cakebaker/chown_remove_duplication_in_tests
chown: remove some duplication in tests
This commit is contained in:
commit
d8f28364f0
1 changed files with 41 additions and 209 deletions
|
@ -748,7 +748,7 @@ fn test_chown_file_notexisting() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_user_from_user() {
|
||||
fn test_chown_no_change_to_user() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
|
@ -759,20 +759,22 @@ fn test_chown_no_change_to_user_from_user() {
|
|||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
for (i, from) in ["42", ":42", "42:42"].iter().enumerate() {
|
||||
let file = i.to_string();
|
||||
at.touch(&file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=42")
|
||||
.arg(format!("--from={from}"))
|
||||
.arg("43")
|
||||
.arg(file)
|
||||
.arg(&file)
|
||||
.succeeds()
|
||||
.stdout_only(format!("ownership of '{file}' retained as {user_name}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_user_from_group() {
|
||||
fn test_chown_no_change_to_group() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
|
@ -782,55 +784,6 @@ fn test_chown_no_change_to_user_from_group() {
|
|||
}
|
||||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=:42")
|
||||
.arg("43")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stdout_only(format!("ownership of '{file}' retained as {user_name}\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_user_from_user_group() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let result = scene.cmd("whoami").run();
|
||||
if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") {
|
||||
return;
|
||||
}
|
||||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=42:42")
|
||||
.arg("43")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stdout_only(format!("ownership of '{file}' retained as {user_name}\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_group_from_user() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let result = scene.cmd("whoami").run();
|
||||
if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") {
|
||||
return;
|
||||
}
|
||||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
|
||||
let result = scene.cmd("id").arg("-ng").run();
|
||||
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
|
||||
return;
|
||||
|
@ -838,20 +791,22 @@ fn test_chown_no_change_to_group_from_user() {
|
|||
let group_name = String::from(result.stdout_str().trim());
|
||||
assert!(!group_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
for (i, from) in ["42", ":42", "42:42"].iter().enumerate() {
|
||||
let file = i.to_string();
|
||||
at.touch(&file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=42")
|
||||
.arg(format!("--from={from}"))
|
||||
.arg(":43")
|
||||
.arg(file)
|
||||
.arg(&file)
|
||||
.succeeds()
|
||||
.stdout_only(format!("ownership of '{file}' retained as {group_name}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_group_from_group() {
|
||||
fn test_chown_no_change_to_user_group() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
|
@ -868,141 +823,18 @@ fn test_chown_no_change_to_group_from_group() {
|
|||
let group_name = String::from(result.stdout_str().trim());
|
||||
assert!(!group_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
for (i, from) in ["42", ":42", "42:42"].iter().enumerate() {
|
||||
let file = i.to_string();
|
||||
at.touch(&file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=:42")
|
||||
.arg(":43")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stdout_only(format!("ownership of '{file}' retained as {group_name}\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_group_from_user_group() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let result = scene.cmd("whoami").run();
|
||||
if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") {
|
||||
return;
|
||||
}
|
||||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
let result = scene.cmd("id").arg("-ng").run();
|
||||
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
|
||||
return;
|
||||
}
|
||||
let group_name = String::from(result.stdout_str().trim());
|
||||
assert!(!group_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=42:42")
|
||||
.arg(":43")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stdout_only(format!("ownership of '{file}' retained as {group_name}\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_user_group_from_user() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let result = scene.cmd("whoami").run();
|
||||
if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") {
|
||||
return;
|
||||
}
|
||||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
|
||||
let result = scene.cmd("id").arg("-ng").run();
|
||||
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
|
||||
return;
|
||||
}
|
||||
let group_name = String::from(result.stdout_str().trim());
|
||||
assert!(!group_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=42")
|
||||
.arg(format!("--from={from}"))
|
||||
.arg("43:43")
|
||||
.arg(file)
|
||||
.arg(&file)
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"ownership of '{file}' retained as {user_name}:{group_name}\n"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_user_group_from_group() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let result = scene.cmd("whoami").run();
|
||||
if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") {
|
||||
return;
|
||||
}
|
||||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
let result = scene.cmd("id").arg("-ng").run();
|
||||
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
|
||||
return;
|
||||
}
|
||||
let group_name = String::from(result.stdout_str().trim());
|
||||
assert!(!group_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=:42")
|
||||
.arg("43:43")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"ownership of '{file}' retained as {user_name}:{group_name}\n"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chown_no_change_to_user_group_from_user_group() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
let result = scene.cmd("whoami").run();
|
||||
if skipping_test_is_okay(&result, "whoami: cannot find name for user ID") {
|
||||
return;
|
||||
}
|
||||
let user_name = String::from(result.stdout_str().trim());
|
||||
assert!(!user_name.is_empty());
|
||||
let result = scene.cmd("id").arg("-ng").run();
|
||||
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
|
||||
return;
|
||||
}
|
||||
let group_name = String::from(result.stdout_str().trim());
|
||||
assert!(!group_name.is_empty());
|
||||
|
||||
let file = "f";
|
||||
at.touch(file);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-v")
|
||||
.arg("--from=42:42")
|
||||
.arg("43:43")
|
||||
.arg(file)
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"ownership of '{file}' retained as {user_name}:{group_name}\n"
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue