-
Notifications
You must be signed in to change notification settings - Fork 0
/
grouper_test.go
42 lines (37 loc) · 1.03 KB
/
grouper_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
package main
import (
"reflect"
"testing"
)
func TestGrouper(t *testing.T) {
tests := []struct {
name string
inputName string
inputDependencies map[string][]string
want map[string][]string
}{
{
name: "single",
inputName: "module_a",
inputDependencies: map[string][]string{"module_a/submodule_a1": []string{"module_b", "module_c"}},
want: map[string][]string{"module_a": []string{"module_b", "module_c"}},
},
{
name: "single",
inputName: "module_a",
inputDependencies: map[string][]string{
"module_a/submodule_a1": []string{"module_b", "module_c"},
"module_a/submodule_a2": []string{"module_c", "module_d"},
},
want: map[string][]string{"module_a": []string{"module_b", "module_c", "module_d"}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := GroupBy(tt.inputName, tt.inputDependencies)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("want %v\ngot: %v", tt.want, got)
}
})
}
}