@@ -64,7 +64,8 @@ func (s *UpgradeConfigTestSuite) addReplicationControllerWithReplicas(name strin
6464
6565func (s * UpgradeConfigTestSuite ) TestInvalidStrategyType () {
6666 const (
67- noExplicitStrategy = "no-explicit-strategy"
67+ noExplicitDeployment = "no-explicit-deployment-strategy"
68+ noExplicitDeploymentConfig = "no-explicit-deployment-config-strategy"
6869 deploymentWithStrategy = "deployment-strategy-recreate"
6970 daemonSetWithStrategy = "daemon-set-strategy-on-delete"
7071 deploymentConfigWithStrategy = "deployment-config-strategy-recreate"
@@ -74,7 +75,8 @@ func (s *UpgradeConfigTestSuite) TestInvalidStrategyType() {
7475 deploymentConfigStrategyType = ocsAppsv1 .DeploymentStrategyTypeRecreate
7576 strategyRegex = "^(RollingUpdate|Rolling)$"
7677 )
77- s .ctx .AddMockDeployment (s .T (), noExplicitStrategy )
78+ s .ctx .AddMockDeployment (s .T (), noExplicitDeployment )
79+ s .ctx .AddMockDeploymentConfig (s .T (), noExplicitDeploymentConfig )
7880 s .addDeploymentWithStrategy (deploymentWithStrategy , appsv1.DeploymentStrategy {Type : deploymentStrategyType })
7981 s .addDaemonSetWithStrategy (daemonSetWithStrategy , appsv1.DaemonSetUpdateStrategy {Type : daemonSetStrategyType })
8082 s .addDeploymentConfigWithStrategy (deploymentConfigWithStrategy , ocsAppsv1.DeploymentStrategy {Type : deploymentConfigStrategyType })
@@ -89,9 +91,8 @@ func (s *UpgradeConfigTestSuite) TestInvalidStrategyType() {
8991 StrategyTypeRegex : strategyRegex ,
9092 },
9193 Diagnostics : map [string ][]diagnostic.Diagnostic {
92- noExplicitStrategy : {
93- {Message : fmt .Sprintf ("object has no strategy type but must match regex %s" , strategyRegex )},
94- },
94+ noExplicitDeployment : {},
95+ noExplicitDeploymentConfig : {},
9596 deploymentWithStrategy : {
9697 {Message : deploymentErrorMsg },
9798 },
@@ -108,6 +109,63 @@ func (s *UpgradeConfigTestSuite) TestInvalidStrategyType() {
108109 })
109110}
110111
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+
111169func (s * UpgradeConfigTestSuite ) TestValidStrategyType () {
112170 const (
113171 deploymentWithStrategy = "deployment-strategy-recreate"
0 commit comments