mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 06:26:44 +00:00
add UT for progress message
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -625,6 +625,15 @@ func TestOnPVBProgress(t *testing.T) {
|
||||
BytesDone: bytesDone,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "patch in progress phase with negative progress values and message",
|
||||
pvb: pvbBuilder().Result(),
|
||||
progress: uploader.Progress{
|
||||
TotalBytes: -1,
|
||||
BytesDone: -1,
|
||||
Message: "some warning message",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "failed to get pvb",
|
||||
pvb: pvbBuilder().Result(),
|
||||
@@ -653,17 +662,25 @@ func TestOnPVBProgress(t *testing.T) {
|
||||
require.NoError(t, r.client.Create(t.Context(), pvb))
|
||||
|
||||
// Create a Progress object
|
||||
progress := &uploader.Progress{
|
||||
TotalBytes: totalBytes,
|
||||
BytesDone: bytesDone,
|
||||
}
|
||||
progress := &test.progress
|
||||
|
||||
r.OnDataPathProgress(ctx, namespace, pvbName, progress)
|
||||
if len(test.needErrs) != 0 && !test.needErrs[0] {
|
||||
updatedPvb := &velerov1api.PodVolumeBackup{}
|
||||
require.NoError(t, r.client.Get(ctx, types.NamespacedName{Name: pvbName, Namespace: namespace}, updatedPvb))
|
||||
assert.Equal(t, test.progress.TotalBytes, updatedPvb.Status.Progress.TotalBytes)
|
||||
assert.Equal(t, test.progress.BytesDone, updatedPvb.Status.Progress.BytesDone)
|
||||
if progress.TotalBytes != -1 {
|
||||
assert.Equal(t, test.progress.TotalBytes, updatedPvb.Status.Progress.TotalBytes)
|
||||
} else {
|
||||
assert.Equal(t, int64(0), updatedPvb.Status.Progress.TotalBytes) // assuming default or original value
|
||||
}
|
||||
if progress.BytesDone != -1 {
|
||||
assert.Equal(t, test.progress.BytesDone, updatedPvb.Status.Progress.BytesDone)
|
||||
} else {
|
||||
assert.Equal(t, int64(0), updatedPvb.Status.Progress.BytesDone) // assuming default or original value
|
||||
}
|
||||
if progress.Message != "" {
|
||||
assert.Contains(t, updatedPvb.Status.Message, progress.Message)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user