coreutils/tests/by-util/test_users.rs
2021-04-18 02:32:43 +03:00

27 lines
712 B
Rust

use crate::common::util::*;
use std::env;
#[test]
fn test_users_noarg() {
new_ucmd!().succeeds();
}
#[test]
fn test_users_check_name() {
let result = TestScenario::new(util_name!()).ucmd_keepenv().succeeds();
// 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_str().is_empty() {
result.stdout_contains(&username);
}
}
}
}