-
Notifications
You must be signed in to change notification settings - Fork 51
/
configurations_test.go
46 lines (41 loc) · 980 Bytes
/
configurations_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
package agollo
import "testing"
func TestConfigurationsDifferent(t *testing.T) {
tests := []struct {
old Configurations
new Configurations
changes []Change
}{
{
Configurations{
"name": "foo",
"age": 18,
"balance": 101.2,
},
Configurations{
"name": "foo",
"age": 19,
"height": 1.82,
},
[]Change{
Change{ChangeTypeUpdate, "age", 19},
Change{ChangeTypeDelete, "balance", 101.2},
Change{ChangeTypeAdd, "height", 1.82},
},
},
}
for _, test := range tests {
changes := test.old.Different(test.new)
if len(changes) != len(test.changes) {
t.Errorf("should be equal (expected=%v, actual=%v)", test.changes, len(changes))
}
for i, actual := range changes {
expected := test.changes[i]
if actual.Type != expected.Type &&
actual.Key != expected.Key &&
actual.Value != expected.Value {
t.Errorf("should be equal (expected=%v, actual=%v)", expected, actual)
}
}
}
}