From 039fc20b65e177267bee59a51d51a8773450e441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wenkai=20Yin=28=E5=B0=B9=E6=96=87=E5=BC=80=29?= Date: Fri, 29 Mar 2024 15:02:30 +0800 Subject: [PATCH] Improve the UT code coverage for pkg/podvolume MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improve the UT code coverage for pkg/podvolume Signed-off-by: Wenkai Yin(尹文开) --- pkg/podvolume/backupper_test.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pkg/podvolume/backupper_test.go b/pkg/podvolume/backupper_test.go index 20b049efc..ade7274df 100644 --- a/pkg/podvolume/backupper_test.go +++ b/pkg/podvolume/backupper_test.go @@ -319,7 +319,7 @@ func TestBackupPodVolumes(t *testing.T) { veleroClientObj []runtime.Object veleroReactors []reactor runtimeScheme *runtime.Scheme - pvbs []*velerov1api.PodVolumeBackup + pvbs int errs []string }{ { @@ -486,6 +486,25 @@ func TestBackupPodVolumes(t *testing.T) { uploaderType: "kopia", bsl: "fake-bsl", }, + { + name: "return completed pvbs", + volumes: []string{ + "fake-volume-1", + }, + sourcePod: createPodObj(true, true, true, 1), + kubeClientObj: []runtime.Object{ + createNodeAgentPodObj(true), + createPVCObj(1), + createPVObj(1, false), + }, + ctlClientObj: []runtime.Object{ + createBackupRepoObj(), + }, + runtimeScheme: scheme, + uploaderType: "kopia", + bsl: "fake-bsl", + pvbs: 1, + }, } // TODO add more verification around PVCBackupSummary returned by "BackupPodVolumes" for _, test := range tests { @@ -533,7 +552,7 @@ func TestBackupPodVolumes(t *testing.T) { } } - assert.Equal(t, test.pvbs, pvbs) + assert.Len(t, pvbs, test.pvbs) }) } }