forked from zabawaba99/firego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapshot_test.go
59 lines (48 loc) · 1.17 KB
/
snapshot_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
package firego
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zabawaba99/firego/sync"
)
func TestDataSnapshotKey(t *testing.T) {
n := sync.Node{Key: "foo"}
d := newSnapshot(&n)
assert.Equal(t, n.Key, d.Key)
}
func TestDataSnapshotValue(t *testing.T) {
n := sync.Node{Value: "foo"}
d := newSnapshot(&n)
assert.Equal(t, n.Value, d.Value)
}
func TestDataSnapshotChild(t *testing.T) {
n := sync.NewNode("", map[string]interface{}{
"one": map[string]interface{}{
"two": map[string]interface{}{
"three": true,
},
},
})
d := newSnapshot(n)
one, ok := d.Child("one")
require.True(t, ok)
assert.Equal(t, one.Key, "one")
assert.Equal(t, one.Value, map[string]interface{}{
"two": map[string]interface{}{
"three": true,
},
})
two, ok := one.Child("two")
require.True(t, ok)
assert.Equal(t, two.Key, "two")
assert.Equal(t, two.Value, map[string]interface{}{
"three": true,
})
three, ok := two.Child("three")
require.True(t, ok)
assert.Equal(t, three.Key, "three")
assert.Equal(t, three.Value, true)
three2, ok := d.Child("one/two/three")
require.True(t, ok)
assert.Equal(t, three, three2)
}