-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry_test.go
98 lines (93 loc) · 1.55 KB
/
entry_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
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
// +build unit
package seq
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestEntry_Add(t *testing.T) {
t.Parallel()
is := assert.New(t)
subject := Entry{
"A": 15,
}
subject.Add("B", 16)
expected := Entry{
"A": 15,
"B": 16,
}
is.Equal(expected, subject, "it should update the entry")
}
func TestNew(t *testing.T) {
t.Parallel()
t.Run("when an interface slice is given", func(t *testing.T) {
t.Parallel()
is := assert.New(t)
type S struct {
B int
}
items := []interface{}{
"A",
Entry{
"X": "Y",
},
nil,
S{15},
&S{16},
}
actual := NewEntry(items)
expected := Entry{
"string": "A",
"X": "Y",
"S": S{15},
"S1": S{16},
}
is.Equal(expected, actual, "it should return the expected entry")
})
t.Run("when multiple items are given", func(t *testing.T) {
t.Parallel()
is := assert.New(t)
type S struct {
B int
}
items := []interface{}{
"A",
Entry{
"X": "Y",
},
S{15},
&S{16},
}
actual := NewEntry(items...)
expected := Entry{
"string": "A",
"X": "Y",
"S": S{15},
"S1": S{16},
}
is.Equal(expected, actual, "it should return the expected entry")
})
}
func TestMerge(t *testing.T) {
t.Parallel()
is := assert.New(t)
inputA := Entry{
"A": 15,
"B": 16,
"C": 17,
}
inputB := Entry{
"A": 20,
"E": 21,
"F": 22,
}
actual := Merge(inputA, inputB)
expected := Entry{
"A": 15,
"B": 16,
"C": 17,
"A1": 20,
"E": 21,
"F": 22,
}
is.Equal(expected, actual, "it should return the expected value")
}