From 5e03a15f47bdc1354554584f4939b303b52d9b75 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 6 Jul 2026 14:07:03 -0500 Subject: feat(music): radio row for name, tag, and manual station search I turned the radio-browser lookup into a Radio row in the playlist buffer: n searches by station name, t searches by tag/genre, m enters a station by hand. Tag search is new (it was a vNext item), and both name and tag hit radio-browser's search endpoint with a name= or tag= field. Freeing n and t moved two keys: single mode goes from t to s, and stop goes from s to S. The header gains a Radio row and the Mode row now reads [s] single. Created station files carry a -Radio suffix (Adroit_Jazz_Underground-Radio.m3u). The pure pieces and the search-URL field are unit-tested (20). Name and tag searches are live-verified. The picker and playback stay a manual check. --- tests/test-music-config--radio.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-music-config--radio.el b/tests/test-music-config--radio.el index b8ce5e30..98368d76 100644 --- a/tests/test-music-config--radio.el +++ b/tests/test-music-config--radio.el @@ -129,13 +129,19 @@ ;;; --------------------------- search-url ------------------------------------- (ert-deftest test-music-radio-search-url-encodes-query-and-limit () - "Normal: the search URL hex-encodes the query and carries the limit." + "Normal: the search URL hex-encodes the query and carries the limit; name is the default field." (let* ((cj/music-radio-search-limit 30) (u (cj/music-radio--search-url "de1.api.radio-browser.info" "smooth jazz"))) - (should (string-match-p "smooth%20jazz" u)) + (should (string-match-p "name=smooth%20jazz" u)) (should (string-match-p "limit=30" u)) (should (string-match-p "/json/stations/search" u)))) +(ert-deftest test-music-radio-search-url-tag-field () + "Normal: field \"tag\" searches the tag= parameter instead of name=." + (let ((u (cj/music-radio--search-url "de1.api.radio-browser.info" "ambient" "tag"))) + (should (string-match-p "tag=ambient" u)) + (should-not (string-match-p "name=ambient" u)))) + (declare-function cj/music-radio--candidates "music-config" (stations)) (declare-function cj/music-radio--write-stations "music-config" (stations dir)) @@ -173,6 +179,16 @@ (should (file-exists-p (car (plist-get result :written))))) (delete-directory dir t)))) +(ert-deftest test-music-radio-write-stations-radio-suffix () + "Normal: a written filename carries the -Radio suffix before .m3u." + (let ((dir (make-temp-file "radio-write-" t))) + (unwind-protect + (let* ((result (cj/music-radio--write-stations (list (test-music-radio--first)) dir)) + (path (car (plist-get result :written)))) + (should (string-suffix-p "-Radio.m3u" path)) + (should (string-match-p "Adroit_Jazz_Underground-Radio\\.m3u\\'" path))) + (delete-directory dir t)))) + (ert-deftest test-music-radio-write-stations-collision-writes-two-files () "Boundary: two same-named stations in one run write two distinct files, no overwrite." (let ((dir (make-temp-file "radio-write-" t))) -- cgit v1.2.3