1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

feature(install): move chown functions into uucore and have install owner support use it

This commit is contained in:
Sylvestre Ledru 2020-11-17 22:13:58 +01:00
parent 015e18731f
commit 55c660b986
7 changed files with 167 additions and 103 deletions

View file

@ -1,6 +1,6 @@
use crate::common::util::*;
use std::os::unix::fs::PermissionsExt;
use rust_users::*;
use std::os::unix::fs::PermissionsExt;
#[test]
fn test_install_help() {
@ -227,6 +227,25 @@ fn test_install_target_new_file_with_group() {
assert!(at.file_exists(&format!("{}/{}", dir, file)));
}
#[test]
fn test_install_target_new_file_with_owner() {
let (at, mut ucmd) = at_and_ucmd!();
let file = "test_install_target_new_filer_file_j";
let dir = "test_install_target_new_file_dir_j";
let uid = get_effective_uid();
at.touch(file);
at.mkdir(dir);
ucmd.arg(file)
.arg("--owner")
.arg(uid.to_string())
.arg(format!("{}/{}", dir, file))
.succeeds()
.no_stderr();
assert!(at.file_exists(file));
assert!(at.file_exists(&format!("{}/{}", dir, file)));
}
#[test]
fn test_install_target_new_file_failing_nonexistent_parent() {