-
Notifications
You must be signed in to change notification settings - Fork 0
/
toolbox_test.go
60 lines (56 loc) · 1.33 KB
/
toolbox_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
package trails_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/xy-planning-network/trails"
)
func TestToolboxFilter(t *testing.T) {
for _, tc := range []struct {
name string
input trails.Toolbox
output trails.Toolbox
}{
{"Nil", nil, make(trails.Toolbox, 0)},
{"Zero", make(trails.Toolbox, 0), make(trails.Toolbox, 0)},
{"Filter-All", make(trails.Toolbox, 4), make(trails.Toolbox, 0)},
{
"From-4-To-1",
trails.Toolbox{
{}, {}, {},
{Actions: make([]trails.ToolAction, 1)},
},
trails.Toolbox{{Actions: make([]trails.ToolAction, 1)}},
},
{
"Keep-All",
trails.Toolbox{
{Actions: make([]trails.ToolAction, 1)},
{Actions: make([]trails.ToolAction, 1)},
},
trails.Toolbox{
{Actions: make([]trails.ToolAction, 1)},
{Actions: make([]trails.ToolAction, 1)},
},
},
} {
t.Run(tc.name, func(t *testing.T) {
require.Equal(t, tc.output, tc.input.Filter())
})
}
}
func TestToolRender(t *testing.T) {
for _, tc := range []struct {
name string
input []trails.ToolAction
output bool
}{
{"Nil", nil, false},
{"Zero", make([]trails.ToolAction, 0), false},
{"Has-Some", make([]trails.ToolAction, 3), true},
} {
t.Run(tc.name, func(t *testing.T) {
actual := trails.Tool{Actions: tc.input}
require.Equal(t, tc.output, actual.Render())
})
}
}