| 85 | |
| 86 | #[test] |
| 87 | fn unset_and_set_api_key() { |
| 88 | // ENV VARIABLES ARE NOT SET |
| 89 | let result = std::panic::catch_unwind(|| Config::new()); |
| 90 | assert!(result.is_err()); |
| 91 | |
| 92 | // NOW WE SET THEM |
| 93 | set_env(); |
| 94 | |
| 95 | let expected = Config { |
| 96 | log_level: "warn".to_string(), |
| 97 | port: 8080, |
| 98 | db_user: "user".to_string(), |
| 99 | db_password: "pass".to_string(), |
| 100 | db_host: "localhost".to_string(), |
| 101 | db_port: 5432, |
| 102 | db_name: "rustwebdev".to_string(), |
| 103 | }; |
| 104 | |
| 105 | let config = Config::new().unwrap(); |
| 106 | |
| 107 | assert_eq!(config, expected); |
| 108 | } |
| 109 | } |