-
Notifications
You must be signed in to change notification settings - Fork 11
/
ls_test.go
56 lines (48 loc) · 1.25 KB
/
ls_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
package main
import (
"testing"
"github.com/facebookgo/ensure"
"github.com/gliderlabs/hostctl/providers"
)
func TestListBasic(t *testing.T) {
t.Parallel()
provider := new(providers.TestProvider)
provider.Create(providers.Host{
Name: "test1",
})
provider.Create(providers.Host{
Name: "test2",
})
stdout, stderr := testRunCmd(t, "hostctl ls", 0, provider, nil)
ensure.DeepEqual(t, stdout.String(), "test1\ntest2\n")
ensure.DeepEqual(t, stderr.String(), "")
}
func TestListPatternSingle(t *testing.T) {
t.Parallel()
provider := new(providers.TestProvider)
provider.Create(providers.Host{
Name: "test1",
})
provider.Create(providers.Host{
Name: "test2",
})
stdout, stderr := testRunCmd(t, "hostctl ls test1", 0, provider, nil)
ensure.DeepEqual(t, stdout.String(), "test1\n")
ensure.DeepEqual(t, stderr.String(), "")
}
func TestListPatternPartial(t *testing.T) {
t.Parallel()
provider := new(providers.TestProvider)
provider.Create(providers.Host{
Name: "test1",
})
provider.Create(providers.Host{
Name: "test2",
})
provider.Create(providers.Host{
Name: "foobar",
})
stdout, stderr := testRunCmd(t, "hostctl ls te*", 0, provider, nil)
ensure.DeepEqual(t, stdout.String(), "test1\ntest2\n")
ensure.DeepEqual(t, stderr.String(), "")
}