From 1f5792ecbb5c15be375beba3bcd47528d17dd80f Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Tue, 2 Oct 2018 14:30:24 -0500 Subject: [PATCH] test: fix unit test nil pointer. Add filesystem to qemu object. Fix mock_hypervisor Signed-off-by: Jose Carlos Venegas Munoz --- virtcontainers/mock_hypervisor.go | 3 +++ virtcontainers/qemu_test.go | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/virtcontainers/mock_hypervisor.go b/virtcontainers/mock_hypervisor.go index c94096b12..5952fb7f9 100644 --- a/virtcontainers/mock_hypervisor.go +++ b/virtcontainers/mock_hypervisor.go @@ -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 } diff --git a/virtcontainers/qemu_test.go b/virtcontainers/qemu_test.go index f4b96ee72..e0b7159b4 100644 --- a/virtcontainers/qemu_test.go +++ b/virtcontainers/qemu_test.go @@ -348,8 +348,10 @@ func TestHotplugRemoveMemory(t *testing.T) { assert := assert.New(t) qemuConfig := newQemuConfig() + fs := &filesystem{} q := &qemu{ - config: qemuConfig, + 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, + config: qemuConfig, + storage: fs, } _, err := q.hotplugAddDevice(&memoryDevice{0, 128}, fsDev)