()
| 573 | // Test searching |
| 574 | #[test] |
| 575 | fn test_search() { |
| 576 | let db_path = get_test_db_path(); |
| 577 | let db = Database::new(db_path.clone()); |
| 578 | |
| 579 | // Insert variety of entities |
| 580 | db.insert_songs(vec![ |
| 581 | create_test_song("Searchable Song", "/path/to/searchable.mp3"), |
| 582 | create_test_song("Another Track", "/path/to/track.mp3"), |
| 583 | ]) |
| 584 | .unwrap(); |
| 585 | |
| 586 | // Create a searchable playlist |
| 587 | let playlist = QueryablePlaylist { |
| 588 | playlist_id: None, |
| 589 | playlist_name: "Searchable Playlist".to_string(), |
| 590 | playlist_coverpath: None, |
| 591 | playlist_path: None, |
| 592 | ..Default::default() |
| 593 | }; |
| 594 | |
| 595 | db.create_playlist(playlist).unwrap(); |
| 596 | |
| 597 | // Search for "Search" |
| 598 | let search_results = db.search_all("Search".to_string()).unwrap(); |
| 599 | |
| 600 | assert!(!search_results.songs.is_empty()); |
| 601 | assert!(!search_results.playlists.is_empty()); |
| 602 | |
| 603 | assert!(search_results.songs.iter().any(|s| s |
| 604 | .song |
| 605 | .title |
| 606 | .as_ref() |
| 607 | .unwrap() |
| 608 | .contains("Searchable"))); |
| 609 | |
| 610 | assert!(search_results |
| 611 | .playlists |
| 612 | .iter() |
| 613 | .any(|p| p.playlist_name.contains("Searchable"))); |
| 614 | |
| 615 | cleanup(&db_path); |
| 616 | } |
| 617 | |
| 618 | // Test analytics operations |
| 619 | #[test] |
nothing calls this directly
no test coverage detected