mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
test(printenv): add some tests
This commit is contained in:
parent
78dc71630c
commit
bee8ab744e
2 changed files with 31 additions and 0 deletions
30
tests/test_printenv.rs
Normal file
30
tests/test_printenv.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
use common::util::*;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_all() {
|
||||||
|
let key = "KEY";
|
||||||
|
env::set_var(key, "VALUE");
|
||||||
|
assert_eq!(env::var(key), Ok("VALUE".to_string()));
|
||||||
|
|
||||||
|
let result = TestScenario::new(util_name!()).ucmd_keepenv().run();
|
||||||
|
assert!(result.success);
|
||||||
|
assert!(result.stdout.contains("HOME="));
|
||||||
|
assert!(result.stdout.contains("KEY=VALUE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_get_var() {
|
||||||
|
let key = "KEY";
|
||||||
|
env::set_var(key, "VALUE");
|
||||||
|
assert_eq!(env::var(key), Ok("VALUE".to_string()));
|
||||||
|
|
||||||
|
let result = TestScenario::new(util_name!())
|
||||||
|
.ucmd_keepenv()
|
||||||
|
.arg("KEY")
|
||||||
|
.run();
|
||||||
|
|
||||||
|
assert!(result.success);
|
||||||
|
assert!(!result.stdout.is_empty());
|
||||||
|
assert!(result.stdout.trim() == "VALUE");
|
||||||
|
}
|
|
@ -77,6 +77,7 @@ generic! {
|
||||||
"nl", test_nl;
|
"nl", test_nl;
|
||||||
"od", test_od;
|
"od", test_od;
|
||||||
"paste", test_paste;
|
"paste", test_paste;
|
||||||
|
"printenv", test_printenv;
|
||||||
"printf", test_printf;
|
"printf", test_printf;
|
||||||
"ptx", test_ptx;
|
"ptx", test_ptx;
|
||||||
"pwd", test_pwd;
|
"pwd", test_pwd;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue