()
| 114 | // Test fetching songs by options |
| 115 | #[test] |
| 116 | fn test_get_songs_by_options() { |
| 117 | let db_path = get_test_db_path(); |
| 118 | let db = Database::new(db_path.clone()); |
| 119 | |
| 120 | // Insert test songs |
| 121 | db.insert_songs(vec![ |
| 122 | create_test_song("Song 1", "/path/to/song1.mp3"), |
| 123 | create_test_song("Song 2", "/path/to/song2.mp3"), |
| 124 | create_test_song("Different", "/path/to/different.mp3"), |
| 125 | ]) |
| 126 | .unwrap(); |
| 127 | |
| 128 | // Test fetching by partial title match |
| 129 | let options = GetSongOptions { |
| 130 | song: Some(SearchableSong { |
| 131 | title: Some("%Song%".to_string()), |
| 132 | ..Default::default() |
| 133 | }), |
| 134 | inclusive: Some(true), |
| 135 | ..Default::default() |
| 136 | }; |
| 137 | |
| 138 | let songs = db.get_songs_by_options(options).unwrap(); |
| 139 | assert_eq!(songs.len(), 2); |
| 140 | assert!(songs |
| 141 | .iter() |
| 142 | .any(|s| s.song.title.as_ref().unwrap() == "Song 1")); |
| 143 | assert!(songs |
| 144 | .iter() |
| 145 | .any(|s| s.song.title.as_ref().unwrap() == "Song 2")); |
| 146 | |
| 147 | // Test fetching by exact path |
| 148 | let options = GetSongOptions { |
| 149 | song: Some(SearchableSong { |
| 150 | path: Some("/path/to/different.mp3".to_string()), |
| 151 | ..Default::default() |
| 152 | }), |
| 153 | inclusive: Some(false), |
| 154 | ..Default::default() |
| 155 | }; |
| 156 | |
| 157 | let songs = db.get_songs_by_options(options).unwrap(); |
| 158 | assert_eq!(songs.len(), 1); |
| 159 | assert_eq!(songs[0].song.title.as_ref().unwrap(), "Different"); |
| 160 | |
| 161 | cleanup(&db_path); |
| 162 | } |
| 163 | |
| 164 | // Test updating a song |
| 165 | #[test] |
nothing calls this directly
no test coverage detected