package borealis import ( "encoding/json" "reflect" "testing" ) var event = Event{ Type: 1, TimestampS: 2, TimestampMS: 3, SequentialID: 4, UniqueID: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}, Payload: map[string]interface{}{}, } var eventJSON = "[1,2,3,4,\"AAECAwQFBgcICQoLDA0ODw==\",{}]" func TestEncodeEvent(t *testing.T) { output, err := json.Marshal(event) if err != nil { t.Error(err) } actual := string(output) expected := eventJSON if actual != expected { t.Errorf("expected %v, but got %v", expected, actual) } } func TestDecodeEvent(t *testing.T) { var actual Event if err := json.Unmarshal([]byte(eventJSON), &actual); err != nil { t.Error(err) } expected := event if !reflect.DeepEqual(actual, expected) { t.Errorf("expected %v, but got %v", expected, actual) } }