mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
chown: remove some duplication in tests
This commit is contained in:
parent
7bc3c5d507
commit
8b9509a55b
1 changed files with 41 additions and 209 deletions
|
@ -744,7 +744,7 @@ fn test_chown_file_notexisting() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chown_no_change_to_user_from_user() {
|
fn test_chown_no_change_to_user() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
|
@ -755,20 +755,22 @@ fn test_chown_no_change_to_user_from_user() {
|
||||||
let user_name = String::from(result.stdout_str().trim());
|
let user_name = String::from(result.stdout_str().trim());
|
||||||
assert!(!user_name.is_empty());
|
assert!(!user_name.is_empty());
|
||||||
|
|
||||||
let file = "f";
|
for (i, from) in ["42", ":42", "42:42"].iter().enumerate() {
|
||||||
at.touch(file);
|
let file = i.to_string();
|
||||||
|
at.touch(&file);
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-v")
|
.arg("-v")
|
||||||
.arg("--from=42")
|
.arg(format!("--from={from}"))
|
||||||
.arg("43")
|
.arg("43")
|
||||||
.arg(file)
|
.arg(&file)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(format!("ownership of '{file}' retained as {user_name}\n"));
|
.stdout_only(format!("ownership of '{file}' retained as {user_name}\n"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chown_no_change_to_user_from_group() {
|
fn test_chown_no_change_to_group() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
|
@ -778,55 +780,6 @@ fn test_chown_no_change_to_user_from_group() {
|
||||||
}
|
}
|
||||||
let user_name = String::from(result.stdout_str().trim());
|
let user_name = String::from(result.stdout_str().trim());
|
||||||
assert!(!user_name.is_empty());
|
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();
|
let result = scene.cmd("id").arg("-ng").run();
|
||||||
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
|
if skipping_test_is_okay(&result, "id: cannot find name for group ID") {
|
||||||
return;
|
return;
|
||||||
|
@ -834,20 +787,22 @@ fn test_chown_no_change_to_group_from_user() {
|
||||||
let group_name = String::from(result.stdout_str().trim());
|
let group_name = String::from(result.stdout_str().trim());
|
||||||
assert!(!group_name.is_empty());
|
assert!(!group_name.is_empty());
|
||||||
|
|
||||||
let file = "f";
|
for (i, from) in ["42", ":42", "42:42"].iter().enumerate() {
|
||||||
at.touch(file);
|
let file = i.to_string();
|
||||||
|
at.touch(&file);
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-v")
|
.arg("-v")
|
||||||
.arg("--from=42")
|
.arg(format!("--from={from}"))
|
||||||
.arg(":43")
|
.arg(":43")
|
||||||
.arg(file)
|
.arg(&file)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(format!("ownership of '{file}' retained as {group_name}\n"));
|
.stdout_only(format!("ownership of '{file}' retained as {group_name}\n"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[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 scene = TestScenario::new(util_name!());
|
||||||
let at = &scene.fixtures;
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
|
@ -864,141 +819,18 @@ fn test_chown_no_change_to_group_from_group() {
|
||||||
let group_name = String::from(result.stdout_str().trim());
|
let group_name = String::from(result.stdout_str().trim());
|
||||||
assert!(!group_name.is_empty());
|
assert!(!group_name.is_empty());
|
||||||
|
|
||||||
let file = "f";
|
for (i, from) in ["42", ":42", "42:42"].iter().enumerate() {
|
||||||
at.touch(file);
|
let file = i.to_string();
|
||||||
|
at.touch(&file);
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
.arg("-v")
|
.arg("-v")
|
||||||
.arg("--from=:42")
|
.arg(format!("--from={from}"))
|
||||||
.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("43:43")
|
.arg("43:43")
|
||||||
.arg(file)
|
.arg(&file)
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_only(format!(
|
.stdout_only(format!(
|
||||||
"ownership of '{file}' retained as {user_name}:{group_name}\n"
|
"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