test: fix unit test nil pointer.

Add filesystem to qemu object.
Fix mock_hypervisor

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
Jose Carlos Venegas Munoz 2018-10-02 14:30:24 -05:00
parent 4697cf3c79
commit 1f5792ecbb
2 changed files with 9 additions and 2 deletions

View File

@ -64,6 +64,9 @@ func (m *mockHypervisor) hotplugAddDevice(devInfo interface{}, devType deviceTyp
switch devType {
case cpuDev:
return m.vCPUs, nil
case memoryDev:
memdev := devInfo.(*memoryDevice)
return memdev.sizeMB, nil
}
return nil, nil
}

View File

@ -348,8 +348,10 @@ func TestHotplugRemoveMemory(t *testing.T) {
assert := assert.New(t)
qemuConfig := newQemuConfig()
fs := &filesystem{}
q := &qemu{
config: qemuConfig,
storage: fs,
}
_, err := q.hotplugRemoveDevice(&memoryDevice{0, 128}, memoryDev)
@ -360,8 +362,10 @@ func TestHotplugUnsupportedDeviceType(t *testing.T) {
assert := assert.New(t)
qemuConfig := newQemuConfig()
fs := &filesystem{}
q := &qemu{
config: qemuConfig,
storage: fs,
}
_, err := q.hotplugAddDevice(&memoryDevice{0, 128}, fsDev)