mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added on wire event format
This commit is contained in:
@@ -1,18 +1,30 @@
|
||||
package events
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
type TestEvent struct {
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
func TestEventCreation(t *testing.T) {
|
||||
|
||||
Convey("When generating slug", t, func() {
|
||||
dashboard := NewDashboard("Grafana Play Home")
|
||||
dashboard.UpdateSlug()
|
||||
Convey("Event to wire event", t, func() {
|
||||
e := TestEvent{
|
||||
Timestamp: time.Unix(1231421123, 223),
|
||||
}
|
||||
|
||||
So(dashboard.Slug, ShouldEqual, "grafana-play-home")
|
||||
wire, _ := ToOnWriteEvent(e)
|
||||
So(e.Timestamp.Unix(), ShouldEqual, wire.Timestamp.Unix())
|
||||
So(wire.EventType, ShouldEqual, "TestEvent")
|
||||
|
||||
json, _ := json.Marshal(wire)
|
||||
So(string(json), ShouldEqual, `{"event_type":"TestEvent","priority":"INFO","timestamp":"2009-01-08T14:25:23.000000223+01:00","payload":{"Timestamp":"2009-01-08T14:25:23.000000223+01:00"}}`)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user