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/config.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/config.rs') diff --git a/tests/config.rs b/tests/config.rs index 70c5034..1702db9 100644 --- a/tests/config.rs +++ b/tests/config.rs @@ -7,13 +7,13 @@ fn test_config_get_scan_interval() { config_path: PathBuf::from("/test/config.toml"), music_paths: vec![], scan_interval: Some(3600), - socket_path: None, lastfm_api_key: None, lastfm_api_secret: None, lastfm_session_key: None, listenbrainz_token: None, volume: None, shuffle: None, + display_format: Some(String::from("$ARTIST - $TRACK")), }; assert_eq!(config.get("scan_interval").unwrap(), "3600"); } @@ -22,7 +22,15 @@ fn test_config_get_scan_interval() { fn test_config_get_not_set() { let config = Config { config_path: PathBuf::from("/test/config.toml"), - ..Default::default() + music_paths: vec![], + scan_interval: None, + lastfm_api_key: None, + lastfm_api_secret: None, + lastfm_session_key: None, + listenbrainz_token: None, + volume: None, + shuffle: None, + display_format: None, }; assert_eq!(config.get("scan_interval").unwrap(), "not set"); } @@ -33,13 +41,13 @@ fn test_config_get_volume() { config_path: PathBuf::from("/test/config.toml"), music_paths: vec![], scan_interval: None, - socket_path: None, lastfm_api_key: None, lastfm_api_secret: None, lastfm_session_key: None, listenbrainz_token: None, volume: Some(75), shuffle: None, + display_format: None, }; assert_eq!(config.get("volume").unwrap(), "75"); } @@ -113,13 +121,13 @@ fn test_config_unset_volume() { config_path: PathBuf::from("/test/config.toml"), music_paths: vec![], scan_interval: None, - socket_path: None, lastfm_api_key: None, lastfm_api_secret: None, lastfm_session_key: None, listenbrainz_token: None, volume: Some(50), shuffle: None, + display_format: None, }; config.unset("volume").unwrap(); assert_eq!(config.volume, None); -- cgit v1.2.3