Newer
Older
Andre Sterba
committed
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package event
import (
"reflect"
"testing"
"github.com/google/uuid"
)
func getTestEntityUUID() uuid.UUID {
id, _ := uuid.Parse("688a264e-5f85-40f8-bd13-afc42fcd5c7a")
return id
}
func TestNewAddEvent(t *testing.T) {
type args struct {
entityID uuid.UUID
}
tests := []struct {
name string
args args
want Event
}{
{
name: "should create a new add event",
args: args{
entityID: getTestEntityUUID(),
},
want: Event{
ID: uuid.New(),
EntityID: getTestEntityUUID(),
Type: TypeAdd,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewAddEvent(tt.args.entityID)
if !reflect.DeepEqual(got.EntityID, tt.want.EntityID) {
t.Errorf("NewAddEvent().EntityID = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got.Type, tt.want.Type) {
t.Errorf("NewAddEvent().Type = %v, want %v", got, tt.want)
}
})
}
}
func TestNewDeleteEvent(t *testing.T) {
type args struct {
entityID uuid.UUID
}
tests := []struct {
name string
args args
want Event
}{
{
name: "should create a new delete event",
args: args{
entityID: getTestEntityUUID(),
},
want: Event{
ID: uuid.New(),
EntityID: getTestEntityUUID(),
Type: TypeDelete,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewDeleteEvent(tt.args.entityID)
if !reflect.DeepEqual(got.EntityID, tt.want.EntityID) {
t.Errorf("NewDeleteEvent().EntityID = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got.Type, tt.want.Type) {
t.Errorf("NewDeleteEvent().Type = %v, want %v", got, tt.want)
}
})
}
}
func TestNewUpdateEvent(t *testing.T) {
type args struct {
entityID uuid.UUID
}
tests := []struct {
name string
args args
want Event
}{
{
name: "should create a new update event",
args: args{
entityID: getTestEntityUUID(),
},
want: Event{
ID: uuid.New(),
EntityID: getTestEntityUUID(),
Type: TypeUpdate,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewUpdateEvent(tt.args.entityID)
if !reflect.DeepEqual(got.EntityID, tt.want.EntityID) {
t.Errorf("NewUpdateEvent().EntityID = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got.Type, tt.want.Type) {
t.Errorf("NewUpdateEvent().Type = %v, want %v", got, tt.want)
}
})
}
}
Fabian Seidl
committed
func TestNewGnmiSubscribeEvent(t *testing.T) {
type args struct {
entityID uuid.UUID
pathsAndValuesMap map[string]string
}
tests := []struct {
name string
args args
want Event
}{
{
Fabian Seidl
committed
name: "should create a new subscribe event",
args: args{
entityID: getTestEntityUUID(),
pathsAndValuesMap: map[string]string{"some/random/path": "val"},
},
want: Event{
ID: uuid.New(),
EntityID: getTestEntityUUID(),
Fabian Seidl
committed
Type: TypeSubscribe,
PathsAndValuesMap: map[string]string{"some/random/path": "val"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Fabian Seidl
committed
got := NewGnmiSubscribeEvent(tt.args.entityID, tt.args.pathsAndValuesMap)
if !reflect.DeepEqual(got.EntityID, tt.want.EntityID) {
Fabian Seidl
committed
t.Errorf("NewGnmiSubscribeEvent().EntityID = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got.Type, tt.want.Type) {
Fabian Seidl
committed
t.Errorf("NewGnmiSubscribeEvent().Type = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got.PathsAndValuesMap, tt.want.PathsAndValuesMap) {
Fabian Seidl
committed
t.Errorf("NewGnmiSubscribeEvent().PathsAndValuesMap = %v, want %v", got, tt.want)