|
| 1 | +mod test_is_update_empty { |
| 2 | + use super::super::is_update_empty; |
| 3 | + use crate::cli::ConfigUpdateArgs; |
| 4 | + |
| 5 | + fn args( |
| 6 | + grpc_uri: Option<&str>, |
| 7 | + rest_uri: Option<&str>, |
| 8 | + api_key: Option<&str>, |
| 9 | + ) -> ConfigUpdateArgs { |
| 10 | + ConfigUpdateArgs { |
| 11 | + interactive: false, |
| 12 | + grpc_uri: grpc_uri.map(String::from), |
| 13 | + rest_uri: rest_uri.map(String::from), |
| 14 | + api_key: api_key.map(String::from), |
| 15 | + } |
| 16 | + } |
| 17 | + |
| 18 | + #[test] |
| 19 | + fn no_flags_is_empty() { |
| 20 | + assert!(is_update_empty(&args(None, None, None))); |
| 21 | + } |
| 22 | + |
| 23 | + #[test] |
| 24 | + fn all_empty_strings_is_empty() { |
| 25 | + assert!(is_update_empty(&args(Some(""), Some(""), Some("")))); |
| 26 | + } |
| 27 | + |
| 28 | + #[test] |
| 29 | + fn any_single_flag_is_not_empty() { |
| 30 | + assert!(!is_update_empty(&args(Some("g"), None, None))); |
| 31 | + assert!(!is_update_empty(&args(None, Some("r"), None))); |
| 32 | + assert!(!is_update_empty(&args(None, None, Some("k")))); |
| 33 | + } |
| 34 | + |
| 35 | + #[test] |
| 36 | + fn all_flags_set_is_not_empty() { |
| 37 | + assert!(!is_update_empty(&args(Some("g"), Some("r"), Some("k")))); |
| 38 | + } |
| 39 | +} |
0 commit comments