Skip to content

Commit f608f12

Browse files
committed
Add test for missing toolkit container
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent bcf9c2e commit f608f12

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

controllers/transforms_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package controllers
1818

1919
import (
20+
"errors"
2021
"path/filepath"
2122
"testing"
2223

@@ -777,11 +778,12 @@ func TestApplyCommonDaemonsetMetadata(t *testing.T) {
777778

778779
func TestTransformToolkit(t *testing.T) {
779780
testCases := []struct {
780-
description string
781-
ds Daemonset // Input DaemonSet
782-
cpSpec *gpuv1.ClusterPolicySpec // Input configuration
783-
runtime gpuv1.Runtime
784-
expectedDs Daemonset // Expected output DaemonSet
781+
description string
782+
ds Daemonset // Input DaemonSet
783+
cpSpec *gpuv1.ClusterPolicySpec // Input configuration
784+
runtime gpuv1.Runtime
785+
expectedError error
786+
expectedDs Daemonset // Expected output DaemonSet
785787
}{
786788
{
787789
description: "transform nvidia-container-toolkit-ctr container",
@@ -1032,6 +1034,12 @@ func TestTransformToolkit(t *testing.T) {
10321034
VolumeMounts: nil,
10331035
}),
10341036
},
1037+
{
1038+
description: "no nvidia-container-toolkit-ctr container",
1039+
ds: NewDaemonset(),
1040+
expectedError: errors.New(`failed to find toolkit container "nvidia-container-toolkit-ctr"`),
1041+
expectedDs: NewDaemonset(),
1042+
},
10351043
}
10361044

10371045
for _, tc := range testCases {
@@ -1042,7 +1050,7 @@ func TestTransformToolkit(t *testing.T) {
10421050
}
10431051

10441052
err := TransformToolkit(tc.ds.DaemonSet, tc.cpSpec, controller)
1045-
require.NoError(t, err)
1053+
require.EqualValues(t, tc.expectedError, err)
10461054
require.EqualValues(t, tc.expectedDs, tc.ds)
10471055
})
10481056
}

0 commit comments

Comments
 (0)