()
| 209 | |
| 210 | #[test] |
| 211 | fn test_update_preferences() -> Result<()> { |
| 212 | let test_dir = setup_test_dir(); |
| 213 | |
| 214 | let prefs = PreferenceConfig::new(test_dir.clone())?; |
| 215 | |
| 216 | // Initial data |
| 217 | let initial_data = TestConfig { |
| 218 | string_value: "initial".to_string(), |
| 219 | number_value: 100, |
| 220 | boolean_value: false, |
| 221 | }; |
| 222 | |
| 223 | // Save initial data |
| 224 | prefs.save_selective("update_key".to_string(), Some(initial_data))?; |
| 225 | |
| 226 | // Updated data |
| 227 | let updated_data = TestConfig { |
| 228 | string_value: "updated".to_string(), |
| 229 | number_value: 200, |
| 230 | boolean_value: true, |
| 231 | }; |
| 232 | |
| 233 | // Update the data |
| 234 | prefs.save_selective("update_key".to_string(), Some(updated_data.clone()))?; |
| 235 | |
| 236 | // Load updated data |
| 237 | let loaded_data: TestConfig = prefs.load_selective("update_key".to_string())?; |
| 238 | |
| 239 | // Verify updated data |
| 240 | assert_eq!( |
| 241 | loaded_data.string_value, "updated", |
| 242 | "String value should be updated" |
| 243 | ); |
| 244 | assert_eq!( |
| 245 | loaded_data.number_value, 200, |
| 246 | "Number value should be updated" |
| 247 | ); |
| 248 | assert!(loaded_data.boolean_value, "Boolean value should be updated"); |
| 249 | |
| 250 | cleanup_test_dir(test_dir); |
| 251 | Ok(()) |
| 252 | } |
| 253 | |
| 254 | #[test] |
| 255 | fn test_has_key() -> Result<()> { |
nothing calls this directly
no test coverage detected