|
@@ -18,7 +18,7 @@ var expectedEvent = Event{
|
|
Payload: map[string]interface{}{},
|
|
Payload: map[string]interface{}{},
|
|
}
|
|
}
|
|
|
|
|
|
-var expectedEventRaw = RawEvent{
|
|
|
|
|
|
+var expectedRawEvent = RawEvent{
|
|
Type: 1,
|
|
Type: 1,
|
|
SequentialID: 2,
|
|
SequentialID: 2,
|
|
TimestampS: 3,
|
|
TimestampS: 3,
|
|
@@ -27,8 +27,8 @@ var expectedEventRaw = RawEvent{
|
|
Payload: map[string]interface{}{},
|
|
Payload: map[string]interface{}{},
|
|
}
|
|
}
|
|
|
|
|
|
-var expectedEventJSON = "[1,2,3,4,\"AAECAwQFBgcICQoLDA0ODw==\",{}]"
|
|
|
|
-var expectedEventCBOR = []byte{0x86, 1, 2, 3, 4, 0x50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0xa0}
|
|
|
|
|
|
+var expectedRawEventJSON = "[1,2,3,4,\"AAECAwQFBgcICQoLDA0ODw==\",{}]"
|
|
|
|
+var expectedRawEventCBOR = []byte{0x86, 1, 2, 3, 4, 0x50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0xa0}
|
|
|
|
|
|
func TestNewRawEvent(t *testing.T) {
|
|
func TestNewRawEvent(t *testing.T) {
|
|
_, err := NewRawEvent(0x1234, make(map[string]interface{}))
|
|
_, err := NewRawEvent(0x1234, make(map[string]interface{}))
|
|
@@ -38,7 +38,7 @@ func TestNewRawEvent(t *testing.T) {
|
|
}
|
|
}
|
|
|
|
|
|
func TestCheckEvent(t *testing.T) {
|
|
func TestCheckEvent(t *testing.T) {
|
|
- actualEvent, err := expectedEventRaw.Check()
|
|
|
|
|
|
+ actualEvent, err := expectedRawEvent.Check()
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.Error(err)
|
|
}
|
|
}
|
|
@@ -47,42 +47,42 @@ func TestCheckEvent(t *testing.T) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func TestEncodeEventJSON(t *testing.T) {
|
|
|
|
- output, err := json.Marshal(expectedEventRaw)
|
|
|
|
|
|
+func TestEncodeRawEventJSON(t *testing.T) {
|
|
|
|
+ output, err := json.Marshal(expectedRawEvent)
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.Error(err)
|
|
}
|
|
}
|
|
actual := string(output)
|
|
actual := string(output)
|
|
- if actual != expectedEventJSON {
|
|
|
|
- t.Errorf("expected %v, but got %v", expectedEventJSON, actual)
|
|
|
|
|
|
+ if actual != expectedRawEventJSON {
|
|
|
|
+ t.Errorf("expected %v, but got %v", expectedRawEventJSON, actual)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func TestEncodeEventCBOR(t *testing.T) {
|
|
|
|
- actual, err := cbor.Marshal(expectedEventRaw)
|
|
|
|
|
|
+func TestEncodeRawEventCBOR(t *testing.T) {
|
|
|
|
+ actual, err := cbor.Marshal(expectedRawEvent)
|
|
if err != nil {
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.Error(err)
|
|
}
|
|
}
|
|
- if !bytes.Equal(actual, expectedEventCBOR) {
|
|
|
|
- t.Errorf("expected %v, but got %v", expectedEventCBOR, actual)
|
|
|
|
|
|
+ if !bytes.Equal(actual, expectedRawEventCBOR) {
|
|
|
|
+ t.Errorf("expected %v, but got %v", expectedRawEventCBOR, actual)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func TestDecodeEventJSON(t *testing.T) {
|
|
|
|
|
|
+func TestDecodeRawEventJSON(t *testing.T) {
|
|
var actual RawEvent
|
|
var actual RawEvent
|
|
- if err := json.Unmarshal([]byte(expectedEventJSON), &actual); err != nil {
|
|
|
|
|
|
+ if err := json.Unmarshal([]byte(expectedRawEventJSON), &actual); err != nil {
|
|
t.Error(err)
|
|
t.Error(err)
|
|
}
|
|
}
|
|
- if !expectedEventRaw.Equal(actual) {
|
|
|
|
- t.Errorf("expected %v, but got %v", expectedEventRaw, actual)
|
|
|
|
|
|
+ if !expectedRawEvent.Equal(actual) {
|
|
|
|
+ t.Errorf("expected %v, but got %v", expectedRawEvent, actual)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-func TestDecodeEventCBOR(t *testing.T) {
|
|
|
|
|
|
+func TestDecodeRawEventCBOR(t *testing.T) {
|
|
var actual RawEvent
|
|
var actual RawEvent
|
|
- if err := cbor.Unmarshal([]byte(expectedEventCBOR), &actual); err != nil {
|
|
|
|
|
|
+ if err := cbor.Unmarshal([]byte(expectedRawEventCBOR), &actual); err != nil {
|
|
t.Error(err)
|
|
t.Error(err)
|
|
}
|
|
}
|
|
- if !expectedEventRaw.Equal(actual) {
|
|
|
|
- t.Errorf("expected %v, but got %v", expectedEventRaw, actual)
|
|
|
|
|
|
+ if !expectedRawEvent.Equal(actual) {
|
|
|
|
+ t.Errorf("expected %v, but got %v", expectedRawEvent, actual)
|
|
}
|
|
}
|
|
}
|
|
}
|