2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2020-05-03 20:38:46 +00:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_users_noarg() {
|
2021-04-17 23:28:06 +00:00
|
|
|
new_ucmd!().succeeds();
|
2020-05-03 20:38:46 +00:00
|
|
|
}
|
|
|
|
#[test]
|
|
|
|
fn test_users_check_name() {
|
2021-04-17 23:28:06 +00:00
|
|
|
let result = TestScenario::new(util_name!()).ucmd_keepenv().succeeds();
|
2020-05-03 20:38:46 +00:00
|
|
|
|
|
|
|
// 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);
|
2021-04-17 23:28:06 +00:00
|
|
|
// println!("result.stdout {}", &result.stdout);
|
|
|
|
if !result.stdout_str().is_empty() {
|
|
|
|
result.stdout_contains(&username);
|
2020-05-03 20:38:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|