Skip to content

Commit 60bbb71

Browse files
committed
test update strategy defaults
1 parent 9ac01a8 commit 60bbb71

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

pkg/templates/updateconfig/template_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,63 @@ func (s *UpgradeConfigTestSuite) TestInvalidStrategyType() {
109109
})
110110
}
111111

112+
func (s *UpgradeConfigTestSuite) TestDefaultStrategyType() {
113+
tests := map[string]struct {
114+
addObject func(name string)
115+
expectedType string
116+
expectedFound bool
117+
}{
118+
"deployment": {
119+
addObject: func(name string) {
120+
s.ctx.AddMockDeployment(s.T(), name)
121+
},
122+
expectedType: string(appsv1.RollingUpdateDeploymentStrategyType),
123+
expectedFound: true,
124+
},
125+
"daemon set": {
126+
addObject: func(name string) {
127+
s.ctx.AddMockDaemonSet(s.T(), name)
128+
},
129+
expectedType: string(appsv1.RollingUpdateDaemonSetStrategyType),
130+
expectedFound: true,
131+
},
132+
"stateful set": {
133+
addObject: func(name string) {
134+
s.ctx.AddObject(name, &appsv1.StatefulSet{})
135+
},
136+
expectedType: string(appsv1.RollingUpdateStatefulSetStrategyType),
137+
expectedFound: true,
138+
},
139+
"deployment config": {
140+
addObject: func(name string) {
141+
s.ctx.AddMockDeploymentConfig(s.T(), name)
142+
},
143+
expectedType: string(ocsAppsv1.DeploymentStrategyTypeRolling),
144+
expectedFound: true,
145+
},
146+
"replication controller": {
147+
addObject: func(name string) {
148+
s.addReplicationControllerWithReplicas(name, 2)
149+
},
150+
expectedFound: false,
151+
},
152+
}
153+
154+
for name, test := range tests {
155+
s.Run(name, func() {
156+
s.SetupTest()
157+
test.addObject(name)
158+
159+
objects := s.ctx.Objects()
160+
s.Require().Len(objects, 1)
161+
defaultType, found := defaultStrategyType(objects[0])
162+
163+
s.Equal(test.expectedFound, found)
164+
s.Equal(test.expectedType, defaultType)
165+
})
166+
}
167+
}
168+
112169
func (s *UpgradeConfigTestSuite) TestValidStrategyType() {
113170
const (
114171
deploymentWithStrategy = "deployment-strategy-recreate"

0 commit comments

Comments
 (0)