mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Add defaulting to tests
This commit is contained in:
parent
fd69001314
commit
a6e0a7b17b
@ -122,6 +122,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
@ -144,6 +147,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
params: []runtime.Object{
|
||||
&corev1.ConfigMap{
|
||||
@ -212,6 +218,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
@ -233,6 +242,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
policyHooks: []generic.PolicyHook[*Policy, *PolicyBinding, PolicyEvaluator]{
|
||||
{
|
||||
@ -317,6 +329,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
@ -338,6 +353,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
policyHooks: []generic.PolicyHook[*Policy, *PolicyBinding, PolicyEvaluator]{
|
||||
{
|
||||
@ -444,6 +462,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
@ -466,6 +487,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
policyHooks: []generic.PolicyHook[*Policy, *PolicyBinding, PolicyEvaluator]{
|
||||
{
|
||||
@ -571,6 +595,9 @@ func TestDispatcher(t *testing.T) {
|
||||
Volumes: []corev1.Volume{{Name: "x"}},
|
||||
},
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
}},
|
||||
},
|
||||
}
|
||||
@ -597,6 +624,11 @@ func TestDispatcher(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Register a fake defaulter since registering the full defaulter adds noise
|
||||
// and creates dep cycles.
|
||||
scheme.AddTypeDefaultingFunc(&appsv1.Deployment{},
|
||||
func(obj interface{}) { fakeSetDefaultForDeployment(obj.(*appsv1.Deployment)) })
|
||||
|
||||
objectInterfaces := admission.NewObjectInterfacesFromScheme(scheme)
|
||||
|
||||
for _, tc := range testCases {
|
||||
@ -673,3 +705,11 @@ func (t testParamScope) Name() meta.RESTScopeName {
|
||||
}
|
||||
|
||||
var _ meta.RESTScope = testParamScope{}
|
||||
|
||||
func fakeSetDefaultForDeployment(obj *appsv1.Deployment) {
|
||||
// Just default strategy type so the tests have a defaulted field to observe
|
||||
strategy := &obj.Spec.Strategy
|
||||
if strategy.Type == "" {
|
||||
strategy.Type = appsv1.RollingUpdateDeploymentStrategyType
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user