Browse Source

Bug fix: don't add albums using `addid`

Currently, album objects are their own id (there's no method for
libmpdel-entity-id for them), so it's not safe to assume that the id
in libmpdel-playlist-add is always either null or a string.
tags/v1.2.0
jao 8 months ago
parent
commit
5c963519ce
2 changed files with 9 additions and 1 deletions
  1. +1
    -1
      libmpdel.el
  2. +8
    -0
      test/libmpdel-test.el

+ 1
- 1
libmpdel.el View File

@@ -900,7 +900,7 @@ ENTITY can also be a list of entities to add.")
(cl-defmethod libmpdel-playlist-add (entity (_ (eql current-playlist)))
(let ((id (libmpdel-entity-id entity)))
(libmpdel-send-command
(if id
(if (and (stringp id) (not (string-empty-p id)))
`("addid %S" ,id)
`("findadd %s" ,(libmpdel-entity-to-criteria entity))))))



+ 8
- 0
test/libmpdel-test.el View File

@@ -262,6 +262,14 @@
(should (equal '("addid \"gmusic:album:Bbtjr2k5632pgyabagduxcg3p4q\"")
(last commands))))))

(ert-deftest libmpdel-test-playlist-add-no-string-id-sends-findadd ()
(let* ((artist (libmpdel--artist-create :name "The Artist"))
(album (libmpdel--album-create :name "The Album" :artist artist)))
(libmpdel-test--with-connection
(libmpdel-playlist-add album 'current-playlist)
(should (equal '("findadd artist \"The Artist\" album \"The Album\"")
(last commands))))))

(ert-deftest libmpdel-test-playlist-add-sends-findadd ()
(let ((song (libmpdel--create-song-from-data
'((Title . "S")


Loading…
Cancel
Save