Skip to content

Commit

Permalink
Add validation test for RuntimeClassName
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Lewis committed Aug 24, 2020
1 parent 7e54b1c commit f969c94
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/apis/serving/k8s_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ func withPodSpecTolerationsEnabled() configOption {
}
}

func withPodSpecRuntimeClassNameEnabled() configOption {
return func(cfg *config.Config) *config.Config {
cfg.Features.PodSpecRuntimeClassName = config.Enabled
return cfg
}
}

func withPodSpecSecurityContextEnabled() configOption {
return func(cfg *config.Config) *config.Config {
cfg.Features.PodSpecSecurityContext = config.Enabled
Expand Down Expand Up @@ -543,6 +550,8 @@ func TestPodSpecMultiContainerValidation(t *testing.T) {
}

func TestPodSpecFeatureValidation(t *testing.T) {
runtimeClassName := "test"

featureData := []struct {
name string
featureSpec corev1.PodSpec
Expand Down Expand Up @@ -597,6 +606,16 @@ func TestPodSpecFeatureValidation(t *testing.T) {
Paths: []string{"tolerations"},
},
cfgOpts: []configOption{withPodSpecTolerationsEnabled()},
}, {
name: "RuntimeClassName",
featureSpec: corev1.PodSpec{
RuntimeClassName: &runtimeClassName,
},
err: &apis.FieldError{
Message: "must not set the field(s)",
Paths: []string{"runtimeClassName"},
},
cfgOpts: []configOption{withPodSpecRuntimeClassNameEnabled()},
}, {
name: "PodSpecSecurityContext",
featureSpec: corev1.PodSpec{
Expand Down

0 comments on commit f969c94

Please sign in to comment.