This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
metadata_test.go
70 lines (64 loc) · 2.12 KB
/
metadata_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package proio
import (
"bytes"
"testing"
)
func TestPushUpdate1(t *testing.T) {
buffer := &bytes.Buffer{}
writer := NewWriter(buffer)
writer.PushMetadata("key1", []byte("value1"))
writer.PushMetadata("key2", []byte("value2"))
event := NewEvent()
writer.Push(event)
writer.PushMetadata("key2", []byte("value3"))
writer.Push(event)
writer.PushMetadata("key1", []byte("value4"))
writer.PushMetadata("key2", []byte("value5"))
writer.Push(event)
writer.Close()
reader := NewReader(buffer)
event1, _ := reader.Next()
event2, _ := reader.Next()
event3, _ := reader.Next()
if string(event1.Metadata["key1"]) != "value1" {
t.Errorf("%v -> %v instead of %v", "key1", event1.Metadata["key1"], "value1")
}
if string(event1.Metadata["key2"]) != "value2" {
t.Errorf("%v -> %v instead of %v", "key2", event1.Metadata["key2"], "value2")
}
if string(event2.Metadata["key2"]) != "value3" {
t.Errorf("%v -> %v instead of %v", "key2", event2.Metadata["key2"], "value3")
}
if string(event3.Metadata["key1"]) != "value4" {
t.Errorf("%v -> %v instead of %v", "key1", event3.Metadata["key1"], "value4")
}
if string(event3.Metadata["key2"]) != "value5" {
t.Errorf("%v -> %v instead of %v", "key2", event3.Metadata["key2"], "value5")
}
reader.Close()
writer = NewWriter(buffer)
writer.Push(event1)
writer.Push(event2)
writer.Push(event3)
writer.Close()
reader = NewReader(buffer)
event1, _ = reader.Next()
event2, _ = reader.Next()
event3, _ = reader.Next()
if string(event1.Metadata["key1"]) != "value1" {
t.Errorf("%v -> %v instead of %v", "key1", event1.Metadata["key1"], "value1")
}
if string(event1.Metadata["key2"]) != "value2" {
t.Errorf("%v -> %v instead of %v", "key2", event1.Metadata["key2"], "value2")
}
if string(event2.Metadata["key2"]) != "value3" {
t.Errorf("%v -> %v instead of %v", "key2", event2.Metadata["key2"], "value3")
}
if string(event3.Metadata["key1"]) != "value4" {
t.Errorf("%v -> %v instead of %v", "key1", event3.Metadata["key1"], "value4")
}
if string(event3.Metadata["key2"]) != "value5" {
t.Errorf("%v -> %v instead of %v", "key2", event3.Metadata["key2"], "value5")
}
reader.Close()
}