From bff38e4f4db211ba277ab14df4646d4238c9e356 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Thu, 26 Aug 2021 15:22:11 -0700 Subject: [PATCH] virtcontainers: clh: Fix the unit test This patch fixes the unit tests over clh.go with the updated client code. Signed-off-by: Bo Chen --- src/runtime/virtcontainers/clh_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index 2ddffbde09..84f5b92e9d 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/virtcontainers/clh_test.go @@ -134,19 +134,19 @@ func TestCloudHypervisorAddNetCheckNetConfigListValues(t *testing.T) { err := clh.addNet(e) assert.Nil(err) - assert.Equal(len(clh.vmconfig.Net), 1) + assert.Equal(len(*clh.vmconfig.Net), 1) if err == nil { - assert.Equal(clh.vmconfig.Net[0].Mac, macTest) - assert.Equal(clh.vmconfig.Net[0].Tap, tapPath) + assert.Equal(*(*clh.vmconfig.Net)[0].Mac, macTest) + assert.Equal(*(*clh.vmconfig.Net)[0].Tap, tapPath) } err = clh.addNet(e) assert.Nil(err) - assert.Equal(len(clh.vmconfig.Net), 2) + assert.Equal(len(*clh.vmconfig.Net), 2) if err == nil { - assert.Equal(clh.vmconfig.Net[1].Mac, macTest) - assert.Equal(clh.vmconfig.Net[1].Tap, tapPath) + assert.Equal(*(*clh.vmconfig.Net)[1].Mac, macTest) + assert.Equal(*(*clh.vmconfig.Net)[1].Tap, tapPath) } } @@ -180,7 +180,7 @@ func TestCloudHypervisorAddNetCheckEnpointTypes(t *testing.T) { t.Errorf("cloudHypervisor.addNet() error = %v, wantErr %v", err, tt.wantErr) } else if err == nil { - assert.Equal(clh.vmconfig.Net[0].Tap, tapPath) + assert.Equal(*(*clh.vmconfig.Net)[0].Tap, tapPath) } }) } @@ -294,8 +294,9 @@ func TestCloudHypervisorResizeMemory(t *testing.T) { clh := cloudHypervisor{} mockClient := &clhClientMock{} - mockClient.vmInfo.Config.Memory.Size = int64(utils.MemUnit(clhConfig.MemorySize) * utils.MiB) - mockClient.vmInfo.Config.Memory.HotplugSize = int64(40 * utils.GiB.ToBytes()) + mockClient.vmInfo.Config = *chclient.NewVmConfig(*chclient.NewKernelConfig("")) + mockClient.vmInfo.Config.Memory = chclient.NewMemoryConfig(int64(utils.MemUnit(clhConfig.MemorySize) * utils.MiB)) + mockClient.vmInfo.Config.Memory.HotplugSize = func(i int64) *int64 { return &i }(int64(40 * utils.GiB.ToBytes())) clh.APIClient = mockClient clh.config = clhConfig