-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecordkey_test.go
79 lines (76 loc) · 1.57 KB
/
recordkey_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
package dal
import (
"testing"
)
func TestGetRecordKeyPath(t *testing.T) {
type args struct {
key *Key
}
tests := []struct {
name string
args args
want string
}{
{
name: "no_parent-string_id",
args: args{key: NewKeyWithID("Kind1", "id1")},
want: "Kind1/id1",
},
{
name: "single_parent-string_id",
args: args{
key: NewKeyWithParentAndID(NewKeyWithID("Parent1", "p1"), "Kind1", "id1"),
},
want: "Parent1/p1/Kind1/id1",
},
{
name: "two_parents-string_id",
args: args{
key: NewKeyWithParentAndID(
NewKeyWithParentAndID(
NewKeyWithID("Parent2", "p2"),
"Parent1", "p1",
),
"Kind1",
"id1",
),
},
want: "Parent2/p2/Parent1/p1/Kind1/id1",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.args.key.String(); got != tt.want {
t.Errorf("key.String() = %v, want %v, child:%+v, Parent: %+v", got, tt.want, tt.args.key, tt.args.key.parent)
}
})
}
}
func TestKeyCollectionPath(t *testing.T) {
type args struct {
key *Key
}
tests := []struct {
name string
args args
want string
}{
{
name: "no_parent-string_id",
args: args{key: NewKeyWithID("Kind1", "id1")},
want: "Kind1",
},
{
name: "single_parent-string_id",
args: args{key: NewKeyWithParentAndID(NewKeyWithID("Parent1", "p1"), "Kind1", "id1")},
want: "Parent1/Kind1",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.args.key.CollectionPath(); got != tt.want {
t.Errorf("CollectionPath() = %v, want %v", got, tt.want)
}
})
}
}