-
Notifications
You must be signed in to change notification settings - Fork 5
/
command_destroy_test.go
50 lines (43 loc) · 1.15 KB
/
command_destroy_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
package vagrant
import (
"testing"
)
func init() {
successfulOutput["destroy"] = `
1534347289,default,metadata,provider,virtualbox
1534347290,default,action,destroy,start
1534347290,default,ui,info,==> default: Forcing shutdown of VM...
1534347292,default,ui,info,==> default: Destroying VM and associated drives...
1534347292,default,action,destroy,end
`
}
func TestDestroyCommand_buildArguments(t *testing.T) {
client := newMockVagrantClient()
t.Run("default", func(t *testing.T) {
cmd := client.Destroy()
args := cmd.buildArguments()
assertArguments(t, args, "--force")
})
t.Run("force", func(t *testing.T) {
cmd := client.Destroy()
cmd.Force = false
args := cmd.buildArguments()
assertArguments(t, args)
})
t.Run("parallel", func(t *testing.T) {
cmd := client.Destroy()
cmd.Parallel = true
args := cmd.buildArguments()
assertArguments(t, args, "--force", "--parallel")
})
}
func TestDestroyCommand_Run(t *testing.T) {
client := newMockVagrantClient()
cmd := client.Destroy()
if err := cmd.Run(); err != nil {
t.Fatalf("Command failed to run: %v", err)
}
if cmd.Error != nil {
t.Fatalf("Command returned error: %v", cmd.Error)
}
}