fix(prometheus): report subsonic error code (#4282)
* fix(prometheus): report subsonic error code * address feedback
This commit is contained in:
@@ -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))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user