Skip to content

Commit 1dee73b

Browse files
committed
Add a test of stickers.
1 parent 90d92b7 commit 1dee73b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/helpers/daemon.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct MpdConfig {
1212
db_file: PathBuf,
1313
music_directory: PathBuf,
1414
playlist_directory: PathBuf,
15+
sticker_file: PathBuf,
1516
config_path: PathBuf,
1617
sock_path: PathBuf,
1718
}
@@ -25,6 +26,7 @@ impl MpdConfig {
2526
db_file: base.join("db"),
2627
music_directory: base.join("music"),
2728
playlist_directory: base.join("playlists"),
29+
sticker_file: base.join("sticker_file"),
2830
config_path: base.join("config"),
2931
sock_path: base.join("sock"),
3032
}
@@ -36,6 +38,7 @@ db_file "{db_file}"
3638
log_file "/dev/null"
3739
music_directory "{music_directory}"
3840
playlist_directory "{playlist_directory}"
41+
sticker_file "{sticker_file}"
3942
bind_to_address "{sock_path}"
4043
audio_output {{
4144
type "null"
@@ -45,6 +48,7 @@ audio_output {{
4548
db_file=self.db_file.display(),
4649
music_directory=self.music_directory.display(),
4750
playlist_directory=self.playlist_directory.display(),
51+
sticker_file=self.sticker_file.display(),
4852
sock_path=self.sock_path.display(),
4953
)
5054
}
@@ -83,11 +87,19 @@ fn sleep() {
8387
thread::sleep(ten_millis);
8488
}
8589

90+
static EMPTY_FLAC_BYTES: &'static [u8] = include_bytes!("../data/empty.flac");
91+
8692
impl Daemon {
8793
pub fn start() -> Daemon {
8894
let temp_dir = TempDir::new("mpd-test").unwrap();
8995
let config = MpdConfig::new(&temp_dir);
9096
config.generate();
97+
98+
File::create(config.music_directory.join("empty.flac"))
99+
.unwrap()
100+
.write_all(EMPTY_FLAC_BYTES)
101+
.unwrap();
102+
91103
let process = Command::new("mpd")
92104
.arg("--no-daemon")
93105
.arg(&config.config_path)

tests/stickers.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
extern crate mpd;
2+
3+
mod helpers;
4+
use helpers::connect;
5+
6+
#[test]
7+
/// Creating a sticker and then getting that sticker returns the value that was set.
8+
fn set_sticker() {
9+
let mut mpd = connect();
10+
11+
static VALUE: &'static str = "value";
12+
13+
mpd.set_sticker("song", "empty.flac", "test_sticker", VALUE).unwrap();
14+
15+
let sticker = mpd.sticker("song", "empty.flac", "test_sticker").unwrap();
16+
assert_eq!(sticker, VALUE);
17+
}

0 commit comments

Comments
 (0)