use std::env; mod util; use util::var; #[test] fn load_example() { util::setup(); // set the value of PATH manually let path = "/original/path"; env::set_var("PATH", path); // values are from the project's .env example loadenv::load().unwrap(); // ensure that PATH didn't get overwritten assert_eq!(var("PATH"), path); // ensure that "UNUSED" didn't get set assert!(env::var("UNUSED").is_err()); // ensure that the rest of the vars are correct assert_eq!(var("REDIS_PORT"), "6379"); assert_eq!(var("REDIS_PASSWORD"), "pLj#CfCUz&^Zjdzgxny4"); assert_eq!(var("DEBUG"), ""); assert_eq!(var("A"), "abc123"); assert_eq!(var("_"), "def456"); assert_eq!(var("OVERWRITE"), "new"); assert_eq!(var("ELEMENT"), "carbon"); assert_eq!(var("STOVE"), "hot"); assert_eq!(var("WORDS"), "the quick brown fox"); }