1717package controllers
1818
1919import (
20+ "errors"
2021 "path/filepath"
2122 "testing"
2223
@@ -777,11 +778,12 @@ func TestApplyCommonDaemonsetMetadata(t *testing.T) {
777778
778779func 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