From 4953e13d9d1fce4ca02aa82d0f13c4a24d07a724 Mon Sep 17 00:00:00 2001 From: korvyashka Date: Mon, 25 Mar 2024 13:13:27 +0400 Subject: [PATCH] Adds: test for detecting title null difference. --- src/commands/edge_app_utils.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/commands/edge_app_utils.rs b/src/commands/edge_app_utils.rs index ad2e9e6..feff3b0 100644 --- a/src/commands/edge_app_utils.rs +++ b/src/commands/edge_app_utils.rs @@ -357,6 +357,40 @@ mod tests { assert_eq!(changes.updates[0].default_value, Some("6".to_owned())); } + #[test] + fn test_detect_changed_settings_when_title_is_null_remotely_should_detect_changes() { + let manifest = create_manifest(); + + let remote_settings = vec![ + Setting { + name: "display_time".to_string(), + type_: SettingType::String, + default_value: Some("5".to_string()), + title: None, + optional: true, + is_global: false, + help_text: "For how long to display the map overlay every time the rover has moved to a new position.".to_string(), + }, + Setting { + name: "google_maps_api_key".to_string(), + type_: SettingType::String, + default_value: Some("6".to_string()), + title: Some("Google maps title".to_string()), + optional: true, + is_global: false, + help_text: "Specify a commercial Google Maps API key. Required due to the app's map feature.".to_string(), + }, + ]; + + // Act + let result = detect_changed_settings(&manifest, &remote_settings); + + // Assert + assert!(result.is_ok()); + let changes = result.unwrap(); + assert_eq!(changes.updates.len(), 1); + } + #[test] fn test_detect_changed_settings_when_no_remote_settings_should_detect_changes() { // Arrange