-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathregistry_test.go
58 lines (53 loc) · 1.13 KB
/
registry_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
package launcher
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseFromArgs(t *testing.T) {
tests := []struct {
name string
input []string
expect []string
}{
{
input: []string{"all,-app2"},
expect: []string{"app1", "app3"},
},
{
input: []string{"all", " -app2 "},
expect: []string{"app1", "app3"},
},
{
input: []string{"all"},
expect: []string{"app1", "app2", "app3"},
},
{
input: []string{" app1", " app2"},
expect: []string{"app1", "app2"},
},
{
input: []string{" app1, app2"},
expect: []string{"app1", "app2"},
},
{
input: []string{"app2", "appnodefault"},
expect: []string{"app2", "appnodefault"},
},
}
RegisterApp(zlog, &AppDef{ID: "app1"})
RegisterApp(zlog, &AppDef{ID: "app2"})
RegisterApp(zlog, &AppDef{ID: "app3"})
RegisterApp(zlog, &AppDef{ID: "appnodefault"})
for idx, test := range tests {
t.Run(fmt.Sprintf("%d", idx), func(t *testing.T) {
res := ParseAppsFromArgs(test.input, func(app string) bool {
if app == "appnodefault" {
return false
}
return true
})
assert.Equal(t, test.expect, res)
})
}
}