MCPcopy Create free account
hub / github.com/Moosync/Moosync / test_update_song

Function test_update_song

src-tauri/database/src/test.rs:166–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164// Test updating a song
165#[test]
166fn test_update_song() {
167 let db_path = get_test_db_path();
168 let db = Database::new(db_path.clone());
169
170 // Insert a test song
171 let songs = db
172 .insert_songs(vec![create_test_song(
173 "Original Title",
174 "/path/to/original.mp3",
175 )])
176 .unwrap();
177 let song_id = songs[0].song._id.clone().unwrap();
178
179 // Update the song
180 let updatable_song = QueryableSong {
181 _id: Some(song_id.clone()),
182 title: Some("Updated Title".to_string()),
183 ..Default::default()
184 };
185
186 db.update_song(updatable_song).unwrap();
187
188 // Fetch the updated song
189 let options = GetSongOptions {
190 song: Some(SearchableSong {
191 _id: Some(song_id),
192 ..Default::default()
193 }),
194 inclusive: Some(false),
195 ..Default::default()
196 };
197
198 let updated_songs = db.get_songs_by_options(options).unwrap();
199 assert_eq!(updated_songs.len(), 1);
200 assert_eq!(
201 updated_songs[0].song.title.as_ref().unwrap(),
202 "Updated Title"
203 );
204
205 cleanup(&db_path);
206}
207
208// Test removing songs
209#[test]

Callers

nothing calls this directly

Calls 6

get_test_db_pathFunction · 0.85
cleanupFunction · 0.85
cloneMethod · 0.80
insert_songsMethod · 0.80
get_songs_by_optionsMethod · 0.80
update_songMethod · 0.45

Tested by

no test coverage detected