Env test util
Just a simple tool to manipulate environment variable in tests.
Usage
When initialising the variable manager with new
, the actual content will be removed and stored
in initial_value
. You can then set a temporary value using the method with
. The environment
variable will then be reset to it's initial value when it will be dropped.
Examples
use TempEnvVar;
set_var; // set the variable to "ORIGINAL"
let variable = new; // read the variable and stores it
assert_eq!;
let variable = variable.with; // set the environment variable with a new content
assert_eq!;
drop;
assert_eq!;
Don't forget to assign the variable in your tests, otherwise the drop
function will be called right away
use TempEnvVar;
set_var; // set the variable to "ORIGINAL"
new.with; // read the variable and stores it
assert_eq!;
let _variable = new.with; // Instead, store it in a variable
assert_eq!;
Real life example