@@ -342,6 +342,46 @@ func TestMountedPVC(t *testing.T) {
342342 var pod corev1.Pod
343343 err = k8sClient .Get (ctx , client .ObjectKeyFromObject (& server ), & pod )
344344 require .NoError (t , err )
345+
346+ // Find the volume on the Pod for this PVC
347+ // Find the Volume for this config file
348+ found := false
349+ volumeName := ""
350+ for _ , v := range pod .Spec .Volumes {
351+ if v .VolumeSource .PersistentVolumeClaim != nil &&
352+ v .VolumeSource .PersistentVolumeClaim .ClaimName == pvc .Name {
353+ // Oh hey found it.
354+ found = true
355+ volumeName = v .Name
356+ break
357+ }
358+ }
359+ assert .True (t , found , "Unable to find Pod volume for the world PVC" )
360+ // Find the three expected volume mounts from this volume
361+ foundWorldVolumeMount := false
362+ foundNetherVolumeMount := false
363+ foundEndVolumeMount := false
364+ container := pod .Spec .Containers [0 ]
365+ for _ , vm := range container .VolumeMounts {
366+ if vm .Name == volumeName {
367+ // Hey it's a mount of our Volume
368+ switch vm .MountPath {
369+ case "/data/world" :
370+ foundWorldVolumeMount = true
371+ assert .Equal (t , "world" , vm .SubPath )
372+ case "/data/world_nether" :
373+ foundNetherVolumeMount = true
374+ assert .Equal (t , "world_nether" , vm .SubPath )
375+ case "/data/world_the_end" :
376+ foundEndVolumeMount = true
377+ assert .Equal (t , "world_the_end" , vm .SubPath )
378+ }
379+ // No default, we tolerate other mounts of the world that aren't these three. We just don't care about them.
380+ }
381+ }
382+ assert .True (t , foundWorldVolumeMount , "Unable to find world volume mount" )
383+ assert .True (t , foundNetherVolumeMount , "Unable to find world_nether volume mount" )
384+ assert .True (t , foundEndVolumeMount , "Unable to find world_the_end volume mount" )
345385}
346386
347387func TestBasicMinecraftServer (t * testing.T ) {
0 commit comments