From 13659f2c307df65973f118e84dcd128987414b87 Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 27 Jul 2026 21:50:26 -0400 Subject: [PATCH] test(artwork): make the artists-first backfill assertion non-vacuous MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The follow-up loop could never fail: once the first "ar" index is asserted to be 0, every non-"ar" element is necessarily at an index greater than 0. A sequence like ["ar", "al", "ar"] passed both assertions, which is exactly the interleaving the check exists to forbid. Assert the partition directly instead: nothing after the first non-artist call may be an artist. Verified by mutation — enqueueing artists a second time after albums now fails the spec. --- core/artwork/housekeeping_test.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/core/artwork/housekeeping_test.go b/core/artwork/housekeeping_test.go index cadb6dbfd..3b75c5186 100644 --- a/core/artwork/housekeeping_test.go +++ b/core/artwork/housekeeping_test.go @@ -2,6 +2,7 @@ package artwork import ( "context" + "slices" "time" "github.com/navidrome/navidrome/conf" @@ -175,18 +176,11 @@ var _ = Describe("Housekeeping", func() { Expect(did).To(BeTrue()) Expect(queueRepo.callKinds).ToNot(BeEmpty()) - artistCallIdx := -1 - for i, k := range queueRepo.callKinds { - if k == "ar" { - artistCallIdx = i - break - } - } - Expect(artistCallIdx).To(Equal(0), "artists must be the first Enqueue call") - for i, k := range queueRepo.callKinds { - if k != "ar" { - Expect(i).To(BeNumerically(">", artistCallIdx)) - } + firstOther := slices.IndexFunc(queueRepo.callKinds, func(k string) bool { return k != "ar" }) + Expect(firstOther).ToNot(Equal(0), "artists must be the first Enqueue call") + if firstOther >= 0 { + Expect(queueRepo.callKinds[firstOther:]).ToNot(ContainElement("ar"), + "no artist Enqueue may follow another kind") } for _, it := range queueRepo.Data {