Add test to Event

This commit is contained in:
Deluan 2021-02-04 12:43:46 -05:00 committed by Joe Stump
parent 7106add40c
commit de79918128
No known key found for this signature in database
GPG Key ID: 29151C3EC48A0EB9
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package events
import (
"testing"
"github.com/deluan/navidrome/log"
"github.com/deluan/navidrome/tests"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestEvents(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelCritical)
RegisterFailHandler(Fail)
RunSpecs(t, "Events Suite")
}

View File

@ -0,0 +1,19 @@
package events
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Event", func() {
It("marshals Event to JSON", func() {
testEvent := TestEvent{Test: "some data"}
json := testEvent.Prepare(&testEvent)
Expect(json).To(Equal(`{"name":"testEvent","Test":"some data"}`))
})
})
type TestEvent struct {
baseEvent
Test string
}