quintodrome/server/subsonic/responses/responses_suite_test.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.1 KiB
Go
Raw Normal View History

package responses
import (
"strings"
"testing"
"github.com/bradleyjkemp/cupaloy/v2"
2020-01-23 15:44:08 -09:00
"github.com/navidrome/navidrome/log"
2022-07-26 12:47:16 -08:00
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/types"
)
func TestSubsonicApiResponses(t *testing.T) {
log.SetLevel(log.LevelError)
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "Subsonic API Responses Suite")
}
func MatchSnapshot() types.GomegaMatcher {
c := cupaloy.New(cupaloy.FailOnUpdate(false))
return &snapshotMatcher{c}
}
type snapshotMatcher struct {
c *cupaloy.Config
}
func (matcher snapshotMatcher) Match(actual interface{}) (success bool, err error) {
actualJson := strings.TrimSpace(string(actual.([]byte)))
err = matcher.c.SnapshotWithName(ginkgo.CurrentSpecReport().FullText(), actualJson)
success = err == nil
return
}
func (matcher snapshotMatcher) FailureMessage(_ interface{}) (message string) {
2020-05-13 12:49:55 -08:00
return "Expected to match saved snapshot\n"
}
func (matcher snapshotMatcher) NegatedFailureMessage(_ interface{}) (message string) {
2020-05-13 12:49:55 -08:00
return "Expected to not match saved snapshot\n"
}