mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
test(users): Introduce two tests
This commit is contained in:
committed by
Roy Ivy III
parent
94aa201ee5
commit
ce047e8330
@@ -0,0 +1,30 @@
|
||||
use common::util::*;
|
||||
use std::env;
|
||||
|
||||
#[test]
|
||||
fn test_users_noarg() {
|
||||
let (_, mut ucmd) = at_and_ucmd!();
|
||||
let result = ucmd.run();
|
||||
assert!(result.success);
|
||||
}
|
||||
#[test]
|
||||
fn test_users_check_name() {
|
||||
let result = TestScenario::new(util_name!()).ucmd_keepenv().run();
|
||||
assert!(result.success);
|
||||
|
||||
// Expectation: USER is often set
|
||||
let key = "USER";
|
||||
|
||||
match env::var(key) {
|
||||
Err(e) => println!("Key {} isn't set. Found {}", &key, e),
|
||||
Ok(username) =>
|
||||
// Check if "users" contains the name of the user
|
||||
{
|
||||
println!("username found {}", &username);
|
||||
println!("result.stdout {}", &result.stdout);
|
||||
if !&result.stdout.is_empty() {
|
||||
assert!(result.stdout.contains(&username))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ unix_only! {
|
||||
"stdbuf", test_stdbuf;
|
||||
"uname", test_uname;
|
||||
"unlink", test_unlink;
|
||||
"users", test_users;
|
||||
"who", test_who;
|
||||
// Be aware of the trailing semicolon after the last item
|
||||
"stat", test_stat
|
||||
|
||||
Reference in New Issue
Block a user