MCPcopy Index your code
hub / github.com/NVIDIA/gpu-operator / TestTransformValidator

Function TestTransformValidator

controllers/transforms_test.go:2766–2883  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2764}
2765
2766func TestTransformValidator(t *testing.T) {
2767 testCases := []struct {
2768 description string
2769 ds Daemonset
2770 cpSpec *gpuv1.ClusterPolicySpec
2771 expectedDs Daemonset
2772 errorExpected bool
2773 }{
2774 {
2775 description: "empty validator spec",
2776 ds: NewDaemonset().
2777 WithInitContainer(corev1.Container{Name: "dummy"}).
2778 WithContainer(corev1.Container{Name: "dummy"}),
2779 cpSpec: &gpuv1.ClusterPolicySpec{
2780 Validator: gpuv1.ValidatorSpec{},
2781 },
2782 expectedDs: NewDaemonset(),
2783 errorExpected: true,
2784 },
2785 {
2786 description: "valid validator spec",
2787 ds: NewDaemonset().
2788 WithInitContainer(corev1.Container{Name: "dummy"}).
2789 WithContainer(corev1.Container{
2790 Name: "dummy",
2791 Image: "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v1.0.0",
2792 ImagePullPolicy: corev1.PullIfNotPresent,
2793 SecurityContext: &corev1.SecurityContext{
2794 RunAsUser: rootUID,
2795 },
2796 }).
2797 WithPullSecret("pull-secret").
2798 WithRuntimeClassName("nvidia"),
2799 cpSpec: &gpuv1.ClusterPolicySpec{
2800 Validator: gpuv1.ValidatorSpec{
2801 Repository: "nvcr.io/nvidia/cloud-native",
2802 Image: "gpu-operator-validator",
2803 Version: "v1.0.0",
2804 ImagePullPolicy: "IfNotPresent",
2805 ImagePullSecrets: []string{"pull-secret"},
2806 },
2807 },
2808 expectedDs: NewDaemonset().
2809 WithInitContainer(corev1.Container{Name: "dummy"}).
2810 WithContainer(corev1.Container{
2811 Name: "dummy",
2812 Image: "nvcr.io/nvidia/cloud-native/gpu-operator-validator:v1.0.0",
2813 ImagePullPolicy: corev1.PullIfNotPresent,
2814 SecurityContext: &corev1.SecurityContext{
2815 RunAsUser: rootUID,
2816 },
2817 }).
2818 WithPullSecret("pull-secret").
2819 WithRuntimeClassName("nvidia"),
2820 },
2821 {
2822 description: "nri plugin enabled",
2823 ds: NewDaemonset().

Callers

nothing calls this directly

Calls 11

NewDaemonsetFunction · 0.85
newBoolPtrFunction · 0.85
TransformValidatorFunction · 0.85
WithContainerMethod · 0.80
WithPullSecretMethod · 0.80
WithPodAnnotationsMethod · 0.80
RunMethod · 0.80
WithNameMethod · 0.80
ErrorMethod · 0.80
WithInitContainerMethod · 0.45
WithRuntimeClassNameMethod · 0.45

Tested by

no test coverage detected