forked from adamlaska/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkill_test.go
More file actions
56 lines (48 loc) · 1.31 KB
/
kill_test.go
File metadata and controls
56 lines (48 loc) · 1.31 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
package commands
import (
"testing"
"github.com/docker/machine/commands/commandstest"
"github.com/docker/machine/drivers/fakedriver"
"github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/libmachinetest"
"github.com/docker/machine/libmachine/state"
"github.com/stretchr/testify/assert"
)
func TestCmdKillMissingMachineName(t *testing.T) {
commandLine := &commandstest.FakeCommandLine{}
api := &libmachinetest.FakeAPI{}
err := cmdKill(commandLine, api)
assert.Equal(t, ErrNoDefault, err)
}
func TestCmdKill(t *testing.T) {
commandLine := &commandstest.FakeCommandLine{
CliArgs: []string{"machineToKill1", "machineToKill2"},
}
api := &libmachinetest.FakeAPI{
Hosts: []*host.Host{
{
Name: "machineToKill1",
Driver: &fakedriver.Driver{
MockState: state.Running,
},
},
{
Name: "machineToKill2",
Driver: &fakedriver.Driver{
MockState: state.Running,
},
},
{
Name: "machine",
Driver: &fakedriver.Driver{
MockState: state.Running,
},
},
},
}
err := cmdKill(commandLine, api)
assert.NoError(t, err)
assert.Equal(t, state.Stopped, libmachinetest.State(api, "machineToKill1"))
assert.Equal(t, state.Stopped, libmachinetest.State(api, "machineToKill2"))
assert.Equal(t, state.Running, libmachinetest.State(api, "machine"))
}