(t *testing.T)
| 306 | } |
| 307 | |
| 308 | func TestTransformForDriverInstallDir(t *testing.T) { |
| 309 | driverInstallDirVolumeName := "driver-install-dir" |
| 310 | testCases := []struct { |
| 311 | description string |
| 312 | driverInstallDir string |
| 313 | input Daemonset |
| 314 | expectedOutput Daemonset |
| 315 | }{ |
| 316 | { |
| 317 | description: "no driver-install-dir volume in daemonset", |
| 318 | driverInstallDir: "/custom-root", |
| 319 | input: NewDaemonset(), |
| 320 | expectedOutput: NewDaemonset(), |
| 321 | }, |
| 322 | { |
| 323 | description: "empty driverInstallDir is a no-op", |
| 324 | driverInstallDir: "", |
| 325 | input: NewDaemonset(). |
| 326 | WithHostPathVolume(driverInstallDirVolumeName, "/run/nvidia/driver", nil). |
| 327 | WithInitContainer( |
| 328 | corev1.Container{ |
| 329 | Name: "driver-validation", |
| 330 | VolumeMounts: []corev1.VolumeMount{ |
| 331 | {Name: driverInstallDirVolumeName, MountPath: "/run/nvidia/driver"}, |
| 332 | }, |
| 333 | }), |
| 334 | expectedOutput: NewDaemonset(). |
| 335 | WithHostPathVolume(driverInstallDirVolumeName, "/run/nvidia/driver", nil). |
| 336 | WithInitContainer( |
| 337 | corev1.Container{ |
| 338 | Name: "driver-validation", |
| 339 | VolumeMounts: []corev1.VolumeMount{ |
| 340 | {Name: driverInstallDirVolumeName, MountPath: "/run/nvidia/driver"}, |
| 341 | }, |
| 342 | }), |
| 343 | }, |
| 344 | { |
| 345 | description: "custom driverInstallDir with driver-install-dir volume", |
| 346 | driverInstallDir: "/custom-root", |
| 347 | input: NewDaemonset(). |
| 348 | WithHostPathVolume(driverInstallDirVolumeName, "/run/nvidia/driver", nil), |
| 349 | expectedOutput: NewDaemonset(). |
| 350 | WithHostPathVolume(driverInstallDirVolumeName, "/custom-root", nil), |
| 351 | }, |
| 352 | { |
| 353 | description: "custom driverInstallDir with driver-install-dir volume and driver-validation initContainer", |
| 354 | driverInstallDir: "/custom-root", |
| 355 | input: NewDaemonset(). |
| 356 | WithHostPathVolume(driverInstallDirVolumeName, "/run/nvidia/driver", nil). |
| 357 | WithInitContainer( |
| 358 | corev1.Container{ |
| 359 | Name: "driver-validation", |
| 360 | VolumeMounts: []corev1.VolumeMount{ |
| 361 | {Name: driverInstallDirVolumeName, MountPath: "/run/nvidia/driver"}, |
| 362 | }, |
| 363 | }), |
| 364 | expectedOutput: NewDaemonset(). |
| 365 | WithHostPathVolume(driverInstallDirVolumeName, "/custom-root", nil). |
nothing calls this directly
no test coverage detected