@@ -225,13 +225,8 @@ func (s *AppControllerTestSuite) TestRunAppPreflights() {
225225 apm .On ("RunAppPreflights" , mock .Anything , mock .MatchedBy (func (opts apppreflightmanager.RunAppPreflightOptions ) bool {
226226 return expectedAPF == opts .AppPreflightSpec
227227 })).Return (nil ),
228- apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (& types.PreflightsOutput {
229- Pass : []types.PreflightsRecord {
230- {
231- Title : "Test Check" ,
232- Message : "Test check passed" ,
233- },
234- },
228+ apm .On ("GetAppPreflightStatus" , mock .Anything ).Return (types.Status {
229+ State : types .StateSucceeded ,
235230 }, nil ),
236231 )
237232 },
@@ -251,13 +246,8 @@ func (s *AppControllerTestSuite) TestRunAppPreflights() {
251246 apm .On ("RunAppPreflights" , mock .Anything , mock .MatchedBy (func (opts apppreflightmanager.RunAppPreflightOptions ) bool {
252247 return expectedAPF == opts .AppPreflightSpec
253248 })).Return (nil ),
254- apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (& types.PreflightsOutput {
255- Pass : []types.PreflightsRecord {
256- {
257- Title : "Test Check" ,
258- Message : "Test check passed" ,
259- },
260- },
249+ apm .On ("GetAppPreflightStatus" , mock .Anything ).Return (types.Status {
250+ State : types .StateSucceeded ,
261251 }, nil ),
262252 )
263253 },
@@ -277,13 +267,8 @@ func (s *AppControllerTestSuite) TestRunAppPreflights() {
277267 apm .On ("RunAppPreflights" , mock .Anything , mock .MatchedBy (func (opts apppreflightmanager.RunAppPreflightOptions ) bool {
278268 return expectedAPF == opts .AppPreflightSpec
279269 })).Return (nil ),
280- apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (& types.PreflightsOutput {
281- Pass : []types.PreflightsRecord {
282- {
283- Title : "Test Check" ,
284- Message : "Test check passed" ,
285- },
286- },
270+ apm .On ("GetAppPreflightStatus" , mock .Anything ).Return (types.Status {
271+ State : types .StateSucceeded ,
287272 }, nil ),
288273 )
289274 },
@@ -303,6 +288,9 @@ func (s *AppControllerTestSuite) TestRunAppPreflights() {
303288 apm .On ("RunAppPreflights" , mock .Anything , mock .MatchedBy (func (opts apppreflightmanager.RunAppPreflightOptions ) bool {
304289 return expectedAPF == opts .AppPreflightSpec
305290 })).Return (nil ),
291+ apm .On ("GetAppPreflightStatus" , mock .Anything ).Return (types.Status {
292+ State : types .StateFailed ,
293+ }, nil ),
306294 apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (& types.PreflightsOutput {
307295 Fail : []types.PreflightsRecord {
308296 {
@@ -316,7 +304,7 @@ func (s *AppControllerTestSuite) TestRunAppPreflights() {
316304 expectedErr : false ,
317305 },
318306 {
319- name : "execution succeeded but failed to get preflight output" ,
307+ name : "failed run preflights with get preflight output error " ,
320308 opts : appcontroller.RunAppPreflightOptions {
321309 PreflightBinaryPath : "/usr/bin/preflight" ,
322310 },
@@ -329,52 +317,32 @@ func (s *AppControllerTestSuite) TestRunAppPreflights() {
329317 apm .On ("RunAppPreflights" , mock .Anything , mock .MatchedBy (func (opts apppreflightmanager.RunAppPreflightOptions ) bool {
330318 return expectedAPF == opts .AppPreflightSpec
331319 })).Return (nil ),
320+ apm .On ("GetAppPreflightStatus" , mock .Anything ).Return (types.Status {
321+ State : types .StateFailed ,
322+ }, nil ),
332323 apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (nil , errors .New ("get output error" )),
333324 )
334325 },
335326 expectedErr : false ,
336327 },
337328 {
338- name : "successful execution with nil preflight output" ,
329+ name : "failed run preflights with nil preflight output" ,
339330 opts : appcontroller.RunAppPreflightOptions {
340331 PreflightBinaryPath : "/usr/bin/preflight" ,
341332 },
342333 currentState : states .StateInfrastructureInstalled ,
343- expectedState : states .StateAppPreflightsSucceeded ,
344- setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
345- mock .InOrder (
346- acm .On ("GetConfigValues" ).Return (types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "test-value" }}, nil ),
347- arm .On ("ExtractAppPreflightSpec" , mock .Anything , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "test-value" }}, mock .Anything , mock .Anything ).Return (expectedAPF , nil ),
348- apm .On ("RunAppPreflights" , mock .Anything , mock .MatchedBy (func (opts apppreflightmanager.RunAppPreflightOptions ) bool {
349- return expectedAPF == opts .AppPreflightSpec
350- })).Return (nil ),
351- apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (nil , nil ),
352- )
353- },
354- expectedErr : false ,
355- },
356- {
357- name : "successful execution with preflight warnings" ,
358- opts : appcontroller.RunAppPreflightOptions {
359- PreflightBinaryPath : "/usr/bin/preflight" ,
360- },
361- currentState : states .StateInfrastructureInstalled ,
362- expectedState : states .StateAppPreflightsSucceeded ,
334+ expectedState : states .StateAppPreflightsExecutionFailed ,
363335 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
364336 mock .InOrder (
365337 acm .On ("GetConfigValues" ).Return (types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "test-value" }}, nil ),
366338 arm .On ("ExtractAppPreflightSpec" , mock .Anything , types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "test-value" }}, mock .Anything , mock .Anything ).Return (expectedAPF , nil ),
367339 apm .On ("RunAppPreflights" , mock .Anything , mock .MatchedBy (func (opts apppreflightmanager.RunAppPreflightOptions ) bool {
368340 return expectedAPF == opts .AppPreflightSpec
369341 })).Return (nil ),
370- apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (& types.PreflightsOutput {
371- Warn : []types.PreflightsRecord {
372- {
373- Title : "Test Check" ,
374- Message : "Test check warning" ,
375- },
376- },
342+ apm .On ("GetAppPreflightStatus" , mock .Anything ).Return (types.Status {
343+ State : types .StateFailed ,
377344 }, nil ),
345+ apm .On ("GetAppPreflightOutput" , mock .Anything ).Return (nil , nil ),
378346 )
379347 },
380348 expectedErr : false ,
0 commit comments