From 455ec54613230f4004a24f8d2798fb0084e00cb4 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 11 May 2026 16:25:49 +0200 Subject: Add display_format config, fix restart command, clean up config code - Add display_format option with get/set/list/unset for customizing track display - Add Track::format() supporting $ARTIST, $ALBUM, $TRACK variables - Update queue, status, notifications to use display_format - Fix restart command using wrong subcommand 'start' -> 'start-daemon' - Remove socket_path from config (now computed at runtime from XDG_RUNTIME_DIR) - Consolidate duplicate save() and save_all() into single save() - Fix redundant .clone().clone() in config.rs - Add todo item for caching config in daemon hot paths --- tests/queue.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/queue.rs') diff --git a/tests/queue.rs b/tests/queue.rs index 438fa23..a73c312 100644 --- a/tests/queue.rs +++ b/tests/queue.rs @@ -248,6 +248,32 @@ fn test_track_display_index_offset() { assert_eq!(t.display_string(4, 10), "05. Artist - Title"); } +#[test] +fn test_track_format_variables() { + let t = track( + "/music/test.mp3", + Some("My Song"), + Some("John Doe"), + Some("Great Album"), + ); + assert_eq!(t.format("$ARTIST - $TRACK"), "John Doe - My Song"); + assert_eq!(t.format("$TRACK ($ALBUM)"), "My Song (Great Album)"); + assert_eq!(t.format("Now playing: $ARTIST"), "Now playing: John Doe"); +} + +#[test] +fn test_track_format_empty_variables() { + let t = track_no_meta("/music/test.mp3"); + assert_eq!(t.format("$ARTIST - $TRACK"), " - test.mp3"); +} + +#[test] +fn test_track_format_missing_variables() { + let t = track("/music/test.mp3", Some("My Song"), Some("John Doe"), None); + assert_eq!(t.format("Track: $TRACK"), "Track: My Song"); + assert_eq!(t.format("Album: $ALBUM"), "Album: "); +} + // ---------- Shuffle ---------- #[test] -- cgit v1.2.3