forked from adamlaska/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm_test.go
More file actions
44 lines (35 loc) · 851 Bytes
/
vm_test.go
File metadata and controls
44 lines (35 loc) · 851 Bytes
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
package virtualbox
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
var stdOutVMInfo = `
storagecontrollerbootable0="on"
memory=1024
cpus=2
"SATA-0-0"="/home/ehazlett/.boot2docker/boot2docker.iso"
"SATA-IsEjected"="off"
"SATA-1-0"="/home/ehazlett/vm/test/disk.vmdk"
"SATA-ImageUUID-1-0"="12345-abcdefg"
"SATA-2-0"="none"
nic1="nat"`
func TestVMInfo(t *testing.T) {
vbox := &VBoxManagerMock{
args: "showvminfo host --machinereadable",
stdOut: stdOutVMInfo,
}
vm, err := getVMInfo("host", vbox)
assert.Equal(t, 2, vm.CPUs)
assert.Equal(t, 1024, vm.Memory)
assert.NoError(t, err)
}
func TestVMInfoError(t *testing.T) {
vbox := &VBoxManagerMock{
args: "showvminfo host --machinereadable",
err: errors.New("BUG"),
}
vm, err := getVMInfo("host", vbox)
assert.Nil(t, vm)
assert.EqualError(t, err, "BUG")
}