|
1 | 1 | //! Tests for filtering ignored properties and verbs during object update operations |
2 | 2 |
|
3 | 3 | use crate::common::*; |
| 4 | +use serde_json::Value; |
| 5 | + |
| 6 | +/// Helper function to convert object/get response (list of strings) to a single string |
| 7 | +fn list_to_string(response: &Value) -> String { |
| 8 | + if let Some(list) = response.get_result_list() { |
| 9 | + list.iter() |
| 10 | + .filter_map(|v| v.as_str()) |
| 11 | + .collect::<Vec<_>>() |
| 12 | + .join("\n") |
| 13 | + } else { |
| 14 | + // Fallback for errors which are still strings |
| 15 | + response.get_result_str().unwrap_or("").to_string() |
| 16 | + } |
| 17 | +} |
4 | 18 |
|
5 | 19 | #[tokio::test] |
6 | 20 | async fn test_object_update_filters_ignored_properties() { |
@@ -34,7 +48,7 @@ async fn test_object_update_filters_ignored_properties() { |
34 | 48 | .await |
35 | 49 | .expect("Failed to get object"); |
36 | 50 |
|
37 | | - let content = get_response.require_result_str("Get object"); |
| 51 | + let content = list_to_string(&get_response); |
38 | 52 |
|
39 | 53 | // Verify test_property was filtered out during update |
40 | 54 | assert!( |
@@ -81,7 +95,7 @@ async fn test_object_update_filters_ignored_verbs() { |
81 | 95 | .await |
82 | 96 | .expect("Failed to get object"); |
83 | 97 |
|
84 | | - let content = get_response.require_result_str("Get object"); |
| 98 | + let content = list_to_string(&get_response); |
85 | 99 |
|
86 | 100 | // Verify test_verb was filtered out during update |
87 | 101 | assert!( |
@@ -132,7 +146,7 @@ async fn test_object_update_preserves_non_ignored_items() { |
132 | 146 | .await |
133 | 147 | .expect("Failed to get object"); |
134 | 148 |
|
135 | | - let content = get_response.require_result_str("Get object"); |
| 149 | + let content = list_to_string(&get_response); |
136 | 150 |
|
137 | 151 | // Verify ignored items are not present |
138 | 152 | assert!( |
|
0 commit comments