mirror of
https://github.com/uutils/coreutils
synced 2024-12-26 21:13:26 +00:00
1c230fd779
Summary of changes in UCommand: * Extend UCommand by builder methods and simplify methods in TestScenario * Simplify code structures where possible. Add documentation. * Store bin_path as PathBuf and util_name as String in all structs * Remove UCommand::util and make bin_path, temp_dir private * Rename UCommand::with_limit -> UCommand::limit Summary of changes in TestScenario: * Rename some parameters in TestScenario methods to be more descriptive * Remove ucmd_keepenv, cmd_keepenv from TestScenario. Use UCommand::keep_env instead.
41 lines
960 B
Rust
41 lines
960 B
Rust
use crate::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()));
|
|
|
|
TestScenario::new(util_name!())
|
|
.ucmd()
|
|
.keep_env()
|
|
.succeeds()
|
|
.stdout_contains("HOME=")
|
|
.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()
|
|
.keep_env()
|
|
.arg("KEY")
|
|
.succeeds();
|
|
|
|
assert!(!result.stdout_str().is_empty());
|
|
assert_eq!(result.stdout_str().trim(), "VALUE");
|
|
}
|
|
|
|
#[test]
|
|
fn test_ignore_equal_var() {
|
|
let scene = TestScenario::new(util_name!());
|
|
// tested by gnu/tests/misc/printenv.sh
|
|
let result = scene.ucmd().env("a=b", "c").arg("a=b").fails();
|
|
|
|
assert!(result.stdout_str().is_empty());
|
|
}
|