diff --git a/src/song.rs b/src/song.rs index ee9b0741..abbb413d 100644 --- a/src/song.rs +++ b/src/song.rs @@ -117,7 +117,9 @@ impl FromIter for Song { "Last-Modified" => result.last_mod = Some(line.1.to_owned()), "Artist" => result.artist = Some(line.1.to_owned()), "Name" => result.name = Some(line.1.to_owned()), - "Time" => result.duration = Some(Duration::from_secs(line.1.parse()?)), + // Deprecated in MPD. + "Time" => (), + "duration" => result.duration = Some(Duration::from_secs_f64(line.1.parse()?)), "Range" => result.range = Some(line.1.parse()?), "Id" => match result.place { None => result.place = Some(QueuePlace { id: Id(line.1.parse()?), pos: 0, prio: 0 }), diff --git a/tests/data/empty.flac b/tests/data/empty.flac deleted file mode 100644 index 4407f5bd..00000000 Binary files a/tests/data/empty.flac and /dev/null differ diff --git a/tests/data/silence.flac b/tests/data/silence.flac new file mode 100644 index 00000000..940c59a1 Binary files /dev/null and b/tests/data/silence.flac differ diff --git a/tests/helpers/daemon.rs b/tests/helpers/daemon.rs index 41d11e20..0ef2d277 100644 --- a/tests/helpers/daemon.rs +++ b/tests/helpers/daemon.rs @@ -88,7 +88,7 @@ fn sleep() { thread::sleep(ten_millis); } -static EMPTY_FLAC_BYTES: &[u8] = include_bytes!("../data/empty.flac"); +static EMPTY_FLAC_BYTES: &[u8] = include_bytes!("../data/silence.flac"); impl Daemon { pub fn start() -> Daemon { @@ -97,7 +97,7 @@ impl Daemon { config.generate(); // TODO: Factor out putting files in the music directory. - File::create(config.music_directory.join("empty.flac")).unwrap().write_all(EMPTY_FLAC_BYTES).unwrap(); + File::create(config.music_directory.join("silence.flac")).unwrap().write_all(EMPTY_FLAC_BYTES).unwrap(); let process = Command::new("mpd") .arg("--no-daemon") diff --git a/tests/song.rs b/tests/song.rs index 3510f99a..17818f5b 100644 --- a/tests/song.rs +++ b/tests/song.rs @@ -1,7 +1,10 @@ extern crate mpd; mod helpers; +use std::time::Duration; + use helpers::connect; +use mpd::Song; #[test] fn currentsong() { @@ -20,6 +23,17 @@ fn queue() { assert_eq!(songs, queue); } +#[test] +fn lsinfo() { + let mut mpd = connect(); + let songs = mpd.lsinfo(Song { file: "silence.flac".into(), ..Default::default() }).unwrap(); + assert_eq!(songs.len(), 1); + + let song = songs.get(0).unwrap(); + assert_eq!(song.file, "silence.flac"); + assert_eq!(song.duration.expect("song should have duration"), Duration::from_millis(500)); +} + #[test] fn rescan_update() { let mut mpd = connect(); diff --git a/tests/stickers.rs b/tests/stickers.rs index 81c13d04..88c35e65 100644 --- a/tests/stickers.rs +++ b/tests/stickers.rs @@ -10,8 +10,8 @@ fn set_sticker() { static VALUE: &str = "value"; - mpd.set_sticker("song", "empty.flac", "test_sticker", VALUE).unwrap(); + mpd.set_sticker("song", "silence.flac", "test_sticker", VALUE).unwrap(); - let sticker = mpd.sticker("song", "empty.flac", "test_sticker").unwrap(); + let sticker = mpd.sticker("song", "silence.flac", "test_sticker").unwrap(); assert_eq!(sticker, VALUE); }