forked from adamlaska/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_rm_test.go
More file actions
79 lines (60 loc) · 2.91 KB
/
create_rm_test.go
File metadata and controls
79 lines (60 loc) · 2.91 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cli
import (
"testing"
"github.com/docker/machine/its"
)
func TestCreateRm(t *testing.T) {
test := its.NewTest(t)
defer test.TearDown()
test.Run("non-existent driver fails", func() {
test.Machine("create -d bogus bogus").Should().Fail(`Driver "bogus" not found. Do you have the plugin binary accessible in your PATH?`)
})
test.Run("non-existent driver fails", func() {
test.Machine("create -d bogus bogus").Should().Fail(`Driver "bogus" not found. Do you have the plugin binary accessible in your PATH?`)
})
test.Run("create with no name fails", func() {
test.Machine("create -d none").Should().Fail(`Error: No machine name specified`)
})
test.Run("create with invalid name fails", func() {
test.Machine("create -d none --url none ∞").Should().Fail(`Error creating machine: Invalid hostname specified. Allowed hostname chars are: 0-9a-zA-Z . -`)
})
test.Run("create with invalid name fails", func() {
test.Machine("create -d none --url none -").Should().Fail(`Error creating machine: Invalid hostname specified. Allowed hostname chars are: 0-9a-zA-Z . -`)
})
test.Run("create with invalid name fails", func() {
test.Machine("create -d none --url none .").Should().Fail(`Error creating machine: Invalid hostname specified. Allowed hostname chars are: 0-9a-zA-Z . -`)
})
test.Run("create with invalid name fails", func() {
test.Machine("create -d none --url none ..").Should().Fail(`Error creating machine: Invalid hostname specified. Allowed hostname chars are: 0-9a-zA-Z . -`)
})
test.Run("create with weird but valid name succeeds", func() {
test.Machine("create -d none --url none a").Should().Succeed()
})
test.Run("fail with extra argument", func() {
test.Machine("create -d none --url none a extra").Should().Fail(`Invalid command line. Found extra arguments [extra]`)
})
test.Run("create with weird but valid name", func() {
test.Machine("create -d none --url none 0").Should().Succeed()
})
test.Run("rm with no name fails", func() {
test.Machine("rm -y").Should().Fail(`Error: Expected to get one or more machine names as arguments`)
})
test.Run("rm non existent machine fails", func() {
test.Machine("rm ∞ -y").Should().Fail(`Error removing host "∞": Host does not exist: "∞"`)
})
test.Run("rm existing machine", func() {
test.Machine("rm 0 -y").Should().Succeed()
})
test.Run("rm ask user confirmation when -y is not provided", func() {
test.Machine("create -d none --url none ba").Should().Succeed()
test.Cmd("echo y | machine rm ba").Should().Succeed()
})
test.Run("rm deny user confirmation when -y is not provided", func() {
test.Machine("create -d none --url none ab").Should().Succeed()
test.Cmd("echo n | machine rm ab").Should().Succeed()
})
test.Run("rm never prompt user confirmation when -f is provided", func() {
test.Machine("create -d none --url none c").Should().Succeed()
test.Machine("rm -f c").Should().Succeed("Successfully removed c")
})
}