@@ -5545,6 +5545,36 @@ func TestUpdateVolumeInfos(t *testing.T) {
55455545 },
55465546 },
55475547 },
5548+ {
5549+ // This is an error case. No crash happen here is good enough.
5550+ name : "VolumeInfo doesn't have SnapshotDataMovementInfo when there is a matching DataUpload" ,
5551+ operations : []* itemoperation.BackupOperation {},
5552+ dataUpload : builder .ForDataUpload ("velero" , "du-1" ).
5553+ CompletionTimestamp (& now ).
5554+ CSISnapshot (& velerov2alpha1.CSISnapshotSpec {VolumeSnapshot : "vs-1" }).
5555+ SnapshotID ("snapshot-id" ).
5556+ Progress (shared.DataMoveOperationProgress {TotalBytes : 1000 }).
5557+ Phase (velerov2alpha1 .DataUploadPhaseCompleted ).
5558+ SourceNamespace ("ns-1" ).
5559+ SourcePVC ("pvc-1" ).
5560+ Result (),
5561+ volumeInfos : []* volume.BackupVolumeInfo {
5562+ {
5563+ PVCName : "pvc-1" ,
5564+ PVCNamespace : "ns-1" ,
5565+ CompletionTimestamp : & metav1.Time {},
5566+ SnapshotDataMovementInfo : nil ,
5567+ },
5568+ },
5569+ expectedVolumeInfos : []* volume.BackupVolumeInfo {
5570+ {
5571+ PVCName : "pvc-1" ,
5572+ PVCNamespace : "ns-1" ,
5573+ CompletionTimestamp : & metav1.Time {},
5574+ SnapshotDataMovementInfo : nil ,
5575+ },
5576+ },
5577+ },
55485578 }
55495579
55505580 for _ , tc := range tests {
@@ -5561,8 +5591,10 @@ func TestUpdateVolumeInfos(t *testing.T) {
55615591 }
55625592
55635593 require .NoError (t , updateVolumeInfos (tc .volumeInfos , unstructures , tc .operations , logger ))
5564- require .Equal (t , tc .expectedVolumeInfos [0 ].CompletionTimestamp , tc .volumeInfos [0 ].CompletionTimestamp )
5565- require .Equal (t , tc .expectedVolumeInfos [0 ].SnapshotDataMovementInfo , tc .volumeInfos [0 ].SnapshotDataMovementInfo )
5594+ if len (tc .expectedVolumeInfos ) > 0 {
5595+ require .Equal (t , tc .expectedVolumeInfos [0 ].CompletionTimestamp , tc .volumeInfos [0 ].CompletionTimestamp )
5596+ require .Equal (t , tc .expectedVolumeInfos [0 ].SnapshotDataMovementInfo , tc .volumeInfos [0 ].SnapshotDataMovementInfo )
5597+ }
55665598 })
55675599 }
55685600}
0 commit comments