@@ -22,6 +22,8 @@ import (
22
22
23
23
"github.com/google/go-cmp/cmp"
24
24
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
+ "k8s.io/apimachinery/pkg/runtime"
26
+ utilruntime "k8s.io/apimachinery/pkg/util/runtime"
25
27
componentbaseconfig "k8s.io/component-base/config/v1alpha1"
26
28
"k8s.io/kube-scheduler/config/v1alpha2"
27
29
"k8s.io/utils/pointer"
@@ -275,3 +277,47 @@ func TestSchedulerDefaults(t *testing.T) {
275
277
})
276
278
}
277
279
}
280
+
281
+ func TestPluginArgsDefaults (t * testing.T ) {
282
+ tests := []struct {
283
+ name string
284
+ in runtime.Object
285
+ want runtime.Object
286
+ }{
287
+ {
288
+ name : "InterPodAffinityArgs empty" ,
289
+ in : & v1alpha2.InterPodAffinityArgs {},
290
+ want : & v1alpha2.InterPodAffinityArgs {
291
+ HardPodAffinityWeight : pointer .Int32Ptr (1 ),
292
+ },
293
+ },
294
+ {
295
+ name : "InterPodAffinityArgs explicit 0" ,
296
+ in : & v1alpha2.InterPodAffinityArgs {
297
+ HardPodAffinityWeight : pointer .Int32Ptr (0 ),
298
+ },
299
+ want : & v1alpha2.InterPodAffinityArgs {
300
+ HardPodAffinityWeight : pointer .Int32Ptr (0 ),
301
+ },
302
+ },
303
+ {
304
+ name : "InterPodAffinityArgs with value" ,
305
+ in : & v1alpha2.InterPodAffinityArgs {
306
+ HardPodAffinityWeight : pointer .Int32Ptr (5 ),
307
+ },
308
+ want : & v1alpha2.InterPodAffinityArgs {
309
+ HardPodAffinityWeight : pointer .Int32Ptr (5 ),
310
+ },
311
+ },
312
+ }
313
+ for _ , tc := range tests {
314
+ scheme := runtime .NewScheme ()
315
+ utilruntime .Must (AddToScheme (scheme ))
316
+ t .Run (tc .name , func (t * testing.T ) {
317
+ scheme .Default (tc .in )
318
+ if diff := cmp .Diff (tc .in , tc .want ); diff != "" {
319
+ t .Errorf ("Got unexpected defaults (-want, +got):\n %s" , diff )
320
+ }
321
+ })
322
+ }
323
+ }
0 commit comments