@@ -65,7 +65,7 @@ func Test_AddPodToVolume_Positive_NewPodNewVolume(t *testing.T) {
65
65
66
66
// Act
67
67
generatedVolumeName , err := dsw .AddPodToVolume (
68
- podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGidValue */ , nil /* seLinuxContainerContexts */ )
68
+ podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGIDValue */ , nil /* seLinuxContainerContexts */ )
69
69
70
70
// Assert
71
71
if err != nil {
@@ -89,8 +89,8 @@ func Test_AddPodToVolume_Positive_ExistingPodExistingVolume(t *testing.T) {
89
89
dsw := NewDesiredStateOfWorld (volumePluginMgr , seLinuxTranslator )
90
90
pod := & v1.Pod {
91
91
ObjectMeta : metav1.ObjectMeta {
92
- Name : "pod3 " ,
93
- UID : "pod3uid " ,
92
+ Name : "pod4 " ,
93
+ UID : "pod4uid " ,
94
94
},
95
95
Spec : v1.PodSpec {
96
96
Volumes : []v1.Volume {
@@ -111,13 +111,20 @@ func Test_AddPodToVolume_Positive_ExistingPodExistingVolume(t *testing.T) {
111
111
112
112
// Act
113
113
generatedVolumeName , err := dsw .AddPodToVolume (
114
- podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGidValue */ , nil /* seLinuxContainerContexts */ )
115
-
116
- // Assert
114
+ podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGIDValue */ , nil /* seLinuxContainerContexts */ )
115
+ if err != nil {
116
+ t .Fatalf ("AddPodToVolume failed. Expected: <no error> Actual: <%v>" , err )
117
+ }
118
+ generatedVolumeName2 , err := dsw .AddPodToVolume (
119
+ podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGIDValue */ , nil /* seLinuxContainerContexts */ )
117
120
if err != nil {
118
121
t .Fatalf ("AddPodToVolume failed. Expected: <no error> Actual: <%v>" , err )
119
122
}
120
123
124
+ // Assert
125
+ if generatedVolumeName != generatedVolumeName2 {
126
+ t .Fatalf ("AddPodToVolume should generate same names, but got %q != %q" , generatedVolumeName , generatedVolumeName2 )
127
+ }
121
128
verifyVolumeExistsDsw (t , generatedVolumeName , "" /* SELinuxContext */ , dsw )
122
129
verifyVolumeExistsInVolumesToMount (
123
130
t , generatedVolumeName , false /* expectReportedInUse */ , dsw )
@@ -318,7 +325,7 @@ func Test_DeletePodFromVolume_Positive_PodExistsVolumeExists(t *testing.T) {
318
325
volumeSpec := & volume.Spec {Volume : & pod .Spec .Volumes [0 ]}
319
326
podName := util .GetUniquePodName (pod )
320
327
generatedVolumeName , err := dsw .AddPodToVolume (
321
- podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGidValue */ , nil /* seLinuxContainerContexts */ )
328
+ podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGIDValue */ , nil /* seLinuxContainerContexts */ )
322
329
if err != nil {
323
330
t .Fatalf ("AddPodToVolume failed. Expected: <no error> Actual: <%v>" , err )
324
331
}
@@ -417,19 +424,19 @@ func Test_MarkVolumesReportedInUse_Positive_NewPodNewVolume(t *testing.T) {
417
424
pod3Name := util .GetUniquePodName (pod3 )
418
425
419
426
generatedVolume1Name , err := dsw .AddPodToVolume (
420
- pod1Name , pod1 , volume1Spec , volume1Spec .Name (), "" /* volumeGidValue */ , nil /* seLinuxContainerContexts */ )
427
+ pod1Name , pod1 , volume1Spec , volume1Spec .Name (), "" /* volumeGIDValue */ , nil /* seLinuxContainerContexts */ )
421
428
if err != nil {
422
429
t .Fatalf ("AddPodToVolume failed. Expected: <no error> Actual: <%v>" , err )
423
430
}
424
431
425
432
generatedVolume2Name , err := dsw .AddPodToVolume (
426
- pod2Name , pod2 , volume2Spec , volume2Spec .Name (), "" /* volumeGidValue */ , nil /* seLinuxContainerContexts */ )
433
+ pod2Name , pod2 , volume2Spec , volume2Spec .Name (), "" /* volumeGIDValue */ , nil /* seLinuxContainerContexts */ )
427
434
if err != nil {
428
435
t .Fatalf ("AddPodToVolume failed. Expected: <no error> Actual: <%v>" , err )
429
436
}
430
437
431
438
generatedVolume3Name , err := dsw .AddPodToVolume (
432
- pod3Name , pod3 , volume3Spec , volume3Spec .Name (), "" /* volumeGidValue */ , nil /* seLinuxContainerContexts */ )
439
+ pod3Name , pod3 , volume3Spec , volume3Spec .Name (), "" /* volumeGIDValue */ , nil /* seLinuxContainerContexts */ )
433
440
if err != nil {
434
441
t .Fatalf ("AddPodToVolume failed. Expected: <no error> Actual: <%v>" , err )
435
442
}
@@ -865,7 +872,7 @@ func Test_AddPodToVolume_SELinuxSinglePod(t *testing.T) {
865
872
866
873
// Act
867
874
generatedVolumeName , err := dsw .AddPodToVolume (
868
- podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGidValue */ , seLinuxContainerContexts )
875
+ podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGIDValue */ , seLinuxContainerContexts )
869
876
870
877
// Assert
871
878
if tc .expectError {
@@ -1214,7 +1221,7 @@ func Test_AddPodToVolume_SELinux_MultiplePods(t *testing.T) {
1214
1221
1215
1222
// Act
1216
1223
generatedVolumeName , err := dsw .AddPodToVolume (
1217
- podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGidValue */ , seLinuxContainerContexts )
1224
+ podName , pod , volumeSpec , volumeSpec .Name (), "" /* volumeGIDValue */ , seLinuxContainerContexts )
1218
1225
1219
1226
// Assert
1220
1227
if err != nil {
@@ -1238,7 +1245,7 @@ func Test_AddPodToVolume_SELinux_MultiplePods(t *testing.T) {
1238
1245
1239
1246
// Act
1240
1247
generatedVolumeName2 , err := dsw .AddPodToVolume (
1241
- pod2Name , pod2 , volumeSpec , volumeSpec .Name (), "" /* volumeGidValue */ , seLinuxContainerContexts )
1248
+ pod2Name , pod2 , volumeSpec , volumeSpec .Name (), "" /* volumeGIDValue */ , seLinuxContainerContexts )
1242
1249
// Assert
1243
1250
if tc .expectError {
1244
1251
if err == nil {
0 commit comments