-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
batch_test.go
63 lines (49 loc) · 944 Bytes
/
batch_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
package main
import (
"path/filepath"
"slices"
"testing"
"github.com/ysmood/got"
)
func TestBatchGroups(t *testing.T) {
g := got.T(t)
batch := Batch{
Groups: map[string]Group{
"$a": {"a", "b"},
"$b": {"c", "$a"},
"$c": {"$b"},
},
}
list, err := batch.GetMembers("$c")
g.E(err)
slices.Sort(list)
g.Eq(list, []string{"a", "b", "c"})
{
batch := Batch{
Groups: map[string]Group{
"$a": {"$b"},
"$b": {"$a"},
},
}
_, err := batch.GetMembers("$a")
g.Is(err, ErrCircularGroupReference)
}
}
func TestBatchFiles(t *testing.T) {
g := got.T(t)
p := "tmp/hello.txt"
g.WriteFile(filepath.FromSlash(p), "hello world!")
batch := Batch{
Files: map[string]Group{
p: {"$c", "d"},
},
Groups: map[string]Group{
"$a": {"a", "b"},
"$b": {"c", "$a"},
"$c": {"$b"},
},
}
list, err := batch.ExpandFiles()
g.E(err)
g.Eq(list[filepath.FromSlash(p)], []string{"a", "b", "c", "d"})
}