mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-15 03:13:38 +00:00
add test for common events
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
)
|
||||
|
||||
func TestEventToJson(t *testing.T) {
|
||||
e := common.Event{
|
||||
Type: "test.event",
|
||||
Data: map[string]any{
|
||||
"key": "value",
|
||||
},
|
||||
}
|
||||
jsonData, err := e.ToJSON()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to convert event to JSON: %v", err)
|
||||
}
|
||||
expectedJson := `{"type":"test.event","data":{"key":"value"}}`
|
||||
if string(jsonData) != expectedJson {
|
||||
t.Errorf("Expected JSON: %s, got: %s", expectedJson, string(jsonData))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user