|
| 1 | +use napi_derive::napi; |
| 2 | + |
| 3 | +#[napi(object)] |
| 4 | +pub struct GetConnectionStringOptions { |
| 5 | + pub container_id_or_name: String, |
| 6 | + pub db_username: Option<String>, |
| 7 | + pub db_password: Option<String>, |
| 8 | + pub verify: Option<bool>, |
| 9 | +} |
| 10 | + |
| 11 | +impl From<GetConnectionStringOptions> for atlas_local::models::GetConnectionStringOptions { |
| 12 | + fn from(source: GetConnectionStringOptions) -> Self { |
| 13 | + Self { |
| 14 | + container_id_or_name: source.container_id_or_name, |
| 15 | + db_username: source.db_username, |
| 16 | + db_password: source.db_password, |
| 17 | + verify: source.verify, |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +// test |
| 23 | +#[cfg(test)] |
| 24 | +mod tests { |
| 25 | + use super::*; |
| 26 | + |
| 27 | + #[test] |
| 28 | + fn test_get_connection_string_options() { |
| 29 | + let options = GetConnectionStringOptions { |
| 30 | + container_id_or_name: "test_container".into(), |
| 31 | + db_username: Some("test_user".into()), |
| 32 | + db_password: Some("test_pass".into()), |
| 33 | + verify: Some(true), |
| 34 | + }; |
| 35 | + |
| 36 | + let get_connection_string_options: atlas_local::models::GetConnectionStringOptions = options.into(); |
| 37 | + |
| 38 | + assert_eq!(get_connection_string_options.container_id_or_name, "test_container"); |
| 39 | + assert_eq!(get_connection_string_options.db_username, Some("test_user".into())); |
| 40 | + assert_eq!(get_connection_string_options.db_password, Some("test_pass".into())); |
| 41 | + assert_eq!(get_connection_string_options.verify, Some(true)); |
| 42 | + } |
| 43 | +} |
0 commit comments