()
| 270 | |
| 271 | #[test] |
| 272 | fn test_preference_events() -> Result<()> { |
| 273 | let test_dir = setup_test_dir(); |
| 274 | |
| 275 | let prefs = PreferenceConfig::new(test_dir.clone())?; |
| 276 | |
| 277 | // Get the receiver |
| 278 | let receiver = prefs.get_receiver(); |
| 279 | |
| 280 | // Save data to trigger an event |
| 281 | let event_key = "event_key"; |
| 282 | prefs.save_selective(event_key.to_string(), Some("event_value"))?; |
| 283 | |
| 284 | // Small delay to ensure event is processed |
| 285 | thread::sleep(Duration::from_millis(50)); |
| 286 | |
| 287 | // Try to receive the event |
| 288 | if let Ok((key, value)) = receiver.try_recv() { |
| 289 | // The actual key is prefixed with "prefs." |
| 290 | let expected_key = format!("prefs.{}", event_key); |
| 291 | assert_eq!( |
| 292 | key, expected_key, |
| 293 | "Event key should match with 'prefs.' prefix" |
| 294 | ); |
| 295 | assert_eq!( |
| 296 | value.as_str().unwrap(), |
| 297 | "event_value", |
| 298 | "Event value should match" |
| 299 | ); |
| 300 | } else { |
| 301 | panic!("No event received"); |
| 302 | } |
| 303 | |
| 304 | cleanup_test_dir(test_dir); |
| 305 | Ok(()) |
| 306 | } |
| 307 | |
| 308 | #[test] |
| 309 | fn test_remove_preference() -> Result<()> { |
nothing calls this directly
no test coverage detected