fix(prometheus): report subsonic error code (#4282)

* fix(prometheus): report subsonic error code

* address feedback
This commit is contained in:
Kendall Garner
2025-06-30 15:54:02 +00:00
committed by GitHub
parent a559414ffa
commit f9c7cc5348
4 changed files with 46 additions and 5 deletions
+15
View File
@@ -12,6 +12,7 @@ import (
"github.com/navidrome/navidrome/utils/gg"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"golang.org/x/net/context"
)
var _ = Describe("sendResponse", func() {
@@ -109,4 +110,18 @@ var _ = Describe("sendResponse", func() {
})
})
It("updates status pointer when an error occurs", func() {
pointer := int32(0)
ctx := context.WithValue(r.Context(), subsonicErrorPointer, &pointer)
r = r.WithContext(ctx)
payload.Status = responses.StatusFailed
payload.Error = &responses.Error{Code: responses.ErrorDataNotFound}
sendResponse(w, r, payload)
Expect(w.Code).To(Equal(http.StatusOK))
Expect(pointer).To(Equal(responses.ErrorDataNotFound))
})
})