()
| 293 | // Test playlist CRUD operations |
| 294 | #[test] |
| 295 | fn test_playlist_operations() { |
| 296 | let db_path = get_test_db_path(); |
| 297 | let db = Database::new(db_path.clone()); |
| 298 | |
| 299 | // Create a playlist |
| 300 | let playlist = QueryablePlaylist { |
| 301 | playlist_id: None, |
| 302 | playlist_name: "Test Playlist".to_string(), |
| 303 | playlist_coverpath: None, |
| 304 | playlist_path: None, |
| 305 | playlist_desc: None, |
| 306 | extension: None, |
| 307 | icon: None, |
| 308 | library_item: None, |
| 309 | ..Default::default() |
| 310 | }; |
| 311 | |
| 312 | let playlist_id = db.create_playlist(playlist).unwrap(); |
| 313 | |
| 314 | // Insert songs |
| 315 | let songs = db |
| 316 | .insert_songs(vec![ |
| 317 | create_test_song("Playlist Song 1", "/path/to/playlist1.mp3"), |
| 318 | create_test_song("Playlist Song 2", "/path/to/playlist2.mp3"), |
| 319 | ]) |
| 320 | .unwrap(); |
| 321 | |
| 322 | // Add songs to playlist |
| 323 | db.add_to_playlist(playlist_id.clone(), songs.clone()) |
| 324 | .unwrap(); |
| 325 | |
| 326 | // Get playlist songs |
| 327 | let playlist_options = QueryablePlaylist { |
| 328 | playlist_id: Some(playlist_id.clone()), |
| 329 | ..Default::default() |
| 330 | }; |
| 331 | |
| 332 | let result = db |
| 333 | .get_entity_by_options(GetEntityOptions { |
| 334 | playlist: Some(playlist_options.clone()), |
| 335 | inclusive: Some(false), |
| 336 | ..Default::default() |
| 337 | }) |
| 338 | .unwrap(); |
| 339 | |
| 340 | // The result is returned as an array of playlists |
| 341 | let playlists = result.as_array().unwrap(); |
| 342 | assert_eq!(playlists.len(), 1); |
| 343 | let playlist = &playlists[0]; |
| 344 | |
| 345 | // Verify we can access the playlist's properties |
| 346 | assert!(playlist["playlist_name"] |
| 347 | .as_str() |
| 348 | .unwrap() |
| 349 | .contains("Test Playlist")); |
| 350 | |
| 351 | // Remove one song from playlist |
| 352 | let song_id_to_remove = songs[0].song._id.clone().unwrap(); |
nothing calls this directly
no test coverage detected