@@ -108,6 +108,40 @@ class PlanCommandIntegrationSpec extends Specification {
108
108
" seed-blacklist-topics" | false
109
109
}
110
110
111
+ void ' test include unchanged flag - #planNam #includeUnchanged' () {
112
+ setup :
113
+ TestUtils . cleanUpCluster()
114
+ TestUtils . seedCluster()
115
+ String planOutputFile = " /tmp/plan.json"
116
+ String file = TestUtils . getResourceFilePath(" plans/${ planName} .yaml" )
117
+ MainCommand mainCommand = new MainCommand ()
118
+ CommandLine cmd = new CommandLine (mainCommand)
119
+
120
+ when :
121
+ int exitCode = -1
122
+ if (includeUnchanged) {
123
+ exitCode = cmd. execute(" -f" , file, " plan" , " --include-unchanged" , " -o" , planOutputFile)
124
+ } else {
125
+ exitCode = cmd. execute(" -f" , file, " plan" , " -o" , planOutputFile)
126
+ }
127
+
128
+ then :
129
+ exitCode == 0
130
+
131
+ when :
132
+ String expected = includeUnchanged ? " ${ planName} -include-unchanged" : planName
133
+ String actualPlan = TestUtils . getFileContent(planOutputFile)
134
+ String expectedPlan = TestUtils . getResourceFileContent(" plans/${ expected} -plan.json" )
135
+
136
+ then :
137
+ JSONAssert . assertEquals (expectedPlan, actualPlan, true )
138
+
139
+ where :
140
+ planName | includeUnchanged
141
+ " seed-basic" | false
142
+ " seed-basic" | true
143
+ }
144
+
111
145
void ' test invalid plans - #planName' () {
112
146
setup :
113
147
ByteArrayOutputStream err = new ByteArrayOutputStream ()
@@ -187,7 +221,7 @@ class PlanCommandIntegrationSpec extends Specification {
187
221
System . setOut(oldOut)
188
222
}
189
223
190
- void ' test plan that has no changes' () {
224
+ void ' test plan that has no changes - #includeUnchanged ' () {
191
225
setup :
192
226
TestUtils . cleanUpCluster()
193
227
TestUtils . seedCluster()
@@ -200,15 +234,21 @@ class PlanCommandIntegrationSpec extends Specification {
200
234
CommandLine cmd = new CommandLine (mainCommand)
201
235
202
236
when :
203
- int exitCode = cmd. execute(" -f" , file, " plan" , " -o" , planOutputFile)
237
+ int exitCode = -1
238
+ if (includeUnchanged) {
239
+ exitCode = cmd. execute(" -f" , file, " plan" , " --include-unchanged" , " -o" , planOutputFile)
240
+ } else {
241
+ exitCode = cmd. execute(" -f" , file, " plan" , " -o" , planOutputFile)
242
+ }
204
243
205
244
then :
206
245
exitCode == 0
207
246
out. toString() == TestUtils . getResourceFileContent(" plans/no-changes-output.txt" )
208
247
209
248
when :
249
+ String expected = includeUnchanged ? " ${ planName} -include-unchanged" : planName
210
250
String actualPlan = TestUtils . getFileContent(planOutputFile)
211
- String expectedPlan = TestUtils . getResourceFileContent(" plans/${ planName } -plan.json" )
251
+ String expectedPlan = TestUtils . getResourceFileContent(" plans/${ expected } -plan.json" )
212
252
213
253
then :
214
254
JSONAssert . assertEquals (expectedPlan, actualPlan, true )
@@ -217,6 +257,8 @@ class PlanCommandIntegrationSpec extends Specification {
217
257
System . setOut(oldOut)
218
258
219
259
where :
220
- planName << [" no-changes" ]
260
+ planName | includeUnchanged
261
+ " no-changes" | false
262
+ " no-changes" | true
221
263
}
222
264
}
0 commit comments