diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-11 16:25:49 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-11 16:25:49 +0200 |
| commit | 455ec54613230f4004a24f8d2798fb0084e00cb4 (patch) | |
| tree | 5ffb7606a11ebf33ea940f068ed046bfda0f0c54 /tests/config.rs | |
| parent | Fix shuffle to not shuffle current track - only shuffle tracks after current ... (diff) | |
| download | rsplayer-455ec54613230f4004a24f8d2798fb0084e00cb4.tar.gz rsplayer-455ec54613230f4004a24f8d2798fb0084e00cb4.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | tests/config.rs | 16 |
1 files changed, 12 insertions, 4 deletions
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() { | |||
| 7 | config_path: PathBuf::from("/test/config.toml"), | 7 | config_path: PathBuf::from("/test/config.toml"), |
| 8 | music_paths: vec![], | 8 | music_paths: vec![], |
| 9 | scan_interval: Some(3600), | 9 | scan_interval: Some(3600), |
| 10 | socket_path: None, | ||
| 11 | lastfm_api_key: None, | 10 | lastfm_api_key: None, |
| 12 | lastfm_api_secret: None, | 11 | lastfm_api_secret: None, |
| 13 | lastfm_session_key: None, | 12 | lastfm_session_key: None, |
| 14 | listenbrainz_token: None, | 13 | listenbrainz_token: None, |
| 15 | volume: None, | 14 | volume: None, |
| 16 | shuffle: None, | 15 | shuffle: None, |
| 16 | display_format: Some(String::from("$ARTIST - $TRACK")), | ||
| 17 | }; | 17 | }; |
| 18 | assert_eq!(config.get("scan_interval").unwrap(), "3600"); | 18 | assert_eq!(config.get("scan_interval").unwrap(), "3600"); |
| 19 | } | 19 | } |
| @@ -22,7 +22,15 @@ fn test_config_get_scan_interval() { | |||
| 22 | fn test_config_get_not_set() { | 22 | fn test_config_get_not_set() { |
| 23 | let config = Config { | 23 | let config = Config { |
| 24 | config_path: PathBuf::from("/test/config.toml"), | 24 | config_path: PathBuf::from("/test/config.toml"), |
| 25 | ..Default::default() | 25 | music_paths: vec![], |
| 26 | scan_interval: None, | ||
| 27 | lastfm_api_key: None, | ||
| 28 | lastfm_api_secret: None, | ||
| 29 | lastfm_session_key: None, | ||
| 30 | listenbrainz_token: None, | ||
| 31 | volume: None, | ||
| 32 | shuffle: None, | ||
| 33 | display_format: None, | ||
| 26 | }; | 34 | }; |
| 27 | assert_eq!(config.get("scan_interval").unwrap(), "not set"); | 35 | assert_eq!(config.get("scan_interval").unwrap(), "not set"); |
| 28 | } | 36 | } |
| @@ -33,13 +41,13 @@ fn test_config_get_volume() { | |||
| 33 | config_path: PathBuf::from("/test/config.toml"), | 41 | config_path: PathBuf::from("/test/config.toml"), |
| 34 | music_paths: vec![], | 42 | music_paths: vec![], |
| 35 | scan_interval: None, | 43 | scan_interval: None, |
| 36 | socket_path: None, | ||
| 37 | lastfm_api_key: None, | 44 | lastfm_api_key: None, |
| 38 | lastfm_api_secret: None, | 45 | lastfm_api_secret: None, |
| 39 | lastfm_session_key: None, | 46 | lastfm_session_key: None, |
| 40 | listenbrainz_token: None, | 47 | listenbrainz_token: None, |
| 41 | volume: Some(75), | 48 | volume: Some(75), |
| 42 | shuffle: None, | 49 | shuffle: None, |
| 50 | display_format: None, | ||
| 43 | }; | 51 | }; |
| 44 | assert_eq!(config.get("volume").unwrap(), "75"); | 52 | assert_eq!(config.get("volume").unwrap(), "75"); |
| 45 | } | 53 | } |
| @@ -113,13 +121,13 @@ fn test_config_unset_volume() { | |||
| 113 | config_path: PathBuf::from("/test/config.toml"), | 121 | config_path: PathBuf::from("/test/config.toml"), |
| 114 | music_paths: vec![], | 122 | music_paths: vec![], |
| 115 | scan_interval: None, | 123 | scan_interval: None, |
| 116 | socket_path: None, | ||
| 117 | lastfm_api_key: None, | 124 | lastfm_api_key: None, |
| 118 | lastfm_api_secret: None, | 125 | lastfm_api_secret: None, |
| 119 | lastfm_session_key: None, | 126 | lastfm_session_key: None, |
| 120 | listenbrainz_token: None, | 127 | listenbrainz_token: None, |
| 121 | volume: Some(50), | 128 | volume: Some(50), |
| 122 | shuffle: None, | 129 | shuffle: None, |
| 130 | display_format: None, | ||
| 123 | }; | 131 | }; |
| 124 | config.unset("volume").unwrap(); | 132 | config.unset("volume").unwrap(); |
| 125 | assert_eq!(config.volume, None); | 133 | assert_eq!(config.volume, None); |
