-
Notifications
You must be signed in to change notification settings - Fork 15
/
utils_test.go
49 lines (39 loc) · 1.01 KB
/
utils_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
package onion
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestMergeLayer(t *testing.T) {
Convey("Test merge data", t, func() {
data1 := map[string]interface{}{
"1": 10,
"2": 20,
"3": 30,
}
data2 := map[string]interface{}{
"1": 100,
}
data3 := map[string]interface{}{
"1": 1000,
"3": 3000,
}
merged := mergeLayersData(data1, data2, data3)
So(merged["1"], ShouldEqual, 1000)
So(merged["2"], ShouldEqual, 20)
So(merged["3"], ShouldEqual, 3000)
merged = mergeLayersData(data3, data2, data1)
So(merged["1"], ShouldEqual, 10)
So(merged["2"], ShouldEqual, 20)
So(merged["3"], ShouldEqual, 30)
merged = mergeLayersData(data3, data1, data2)
So(merged["1"], ShouldEqual, 100)
So(merged["2"], ShouldEqual, 20)
So(merged["3"], ShouldEqual, 30)
merged = mergeLayersData(data1)
So(merged["1"], ShouldEqual, 10)
So(merged["2"], ShouldEqual, 20)
So(merged["3"], ShouldEqual, 30)
merged = mergeLayersData()
So(len(merged), ShouldEqual, 0)
})
}