forked from einride/aip-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rangeparents_test.go
65 lines (58 loc) · 941 Bytes
/
rangeparents_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
package resourcename
import (
"testing"
"gotest.tools/v3/assert"
)
func TestRangeParents(t *testing.T) {
t.Parallel()
for _, tt := range []struct {
name string
input string
expected []string
}{
{
name: "empty",
input: "",
},
{
name: "singleton",
input: "foo",
},
{
name: "single",
input: "foo/bar",
expected: []string{
"foo",
},
},
{
name: "multiple",
input: "foo/bar/baz/123",
expected: []string{
"foo",
"foo/bar",
"foo/bar/baz",
},
},
{
name: "full",
input: "//test.example.com/foo/bar/baz/123",
expected: []string{
"foo",
"foo/bar",
"foo/bar/baz",
},
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var actual []string
RangeParents(tt.input, func(parent string) bool {
actual = append(actual, parent)
return true
})
assert.DeepEqual(t, tt.expected, actual)
})
}
}