mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 09:48:03 +00:00
chown: Add tests
This commit is contained in:
parent
59ed78209a
commit
19676a3ca2
2 changed files with 47 additions and 0 deletions
46
tests/test_chown.rs
Normal file
46
tests/test_chown.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use common::util::*;
|
||||
|
||||
extern crate uu_chown;
|
||||
pub use self::uu_chown::*;
|
||||
|
||||
static UTIL_NAME: &'static str = "chown";
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_passwd {
|
||||
use super::passwd::*;
|
||||
|
||||
#[test]
|
||||
fn test_getuid() {
|
||||
assert_eq!(0, getuid("root").unwrap());
|
||||
assert_eq!(99, getuid("99").unwrap());
|
||||
assert!(getuid("88888888").is_err());
|
||||
assert!(getuid("agroupthatdoesntexist").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_getgid() {
|
||||
assert_eq!(0, getgid("root").unwrap());
|
||||
assert_eq!(99, getgid("99").unwrap());
|
||||
assert!(getgid("88888888").is_err());
|
||||
assert!(getgid("agroupthatdoesntexist").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_uid2usr() {
|
||||
assert_eq!("root", uid2usr(0).unwrap());
|
||||
assert!(uid2usr(88888888).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gid2grp() {
|
||||
assert_eq!("root", gid2grp(0).unwrap());
|
||||
assert!(gid2grp(88888888).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_option() {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.arg("-w").arg("-q").arg("/");
|
||||
ucmd.fails();
|
||||
}
|
|
@ -26,6 +26,7 @@ macro_rules! unix_only {
|
|||
}
|
||||
unix_only! {
|
||||
"chmod", test_chmod;
|
||||
"chown", test_chown;
|
||||
"mv", test_mv;
|
||||
"pathchk", test_pathchk;
|
||||
"stdbuf", test_stdbuf;
|
||||
|
|
Loading…
Reference in a new issue