forked from juju/terraform-provider-juju
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(application): wait for complete on destroy
When destroying an application, wait for it to be destroyed before returning. Issue juju#521 and maybe others. Otherwise terraform fails when RequireReplace is set.
- Loading branch information
Showing
3 changed files
with
139 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,6 +364,58 @@ func (s *ApplicationSuite) TestReadApplicationRetryNotFoundStorageNotFoundError( | |
s.Assert().Equal("[email protected]", resp.Base) | ||
} | ||
|
||
func (s *ApplicationSuite) TestDestroyApplicationDoNotFailOnNotFound() { | ||
defer s.setupMocks(s.T()).Finish() | ||
s.mockSharedClient.EXPECT().ModelType(gomock.Any()).Return(model.IAAS, nil).AnyTimes() | ||
|
||
appName := "testapplication" | ||
aExp := s.mockApplicationClient.EXPECT() | ||
|
||
aExp.DestroyApplications(gomock.Any()).Return([]params.DestroyApplicationResult{{ | ||
Error: ¶ms.Error{Message: `application "testapplication" not found`, Code: "not found"}, | ||
}}, nil) | ||
|
||
client := s.getApplicationsClient() | ||
err := client.DestroyApplication(context.Background(), | ||
&DestroyApplicationInput{ | ||
ApplicationName: appName, | ||
ModelName: s.testModelName, | ||
}) | ||
s.Require().NoError(err) | ||
} | ||
|
||
func (s *ApplicationSuite) TestDestroyApplicationRetry() { | ||
defer s.setupMocks(s.T()).Finish() | ||
s.mockSharedClient.EXPECT().ModelType(gomock.Any()).Return(model.IAAS, nil).AnyTimes() | ||
|
||
appName := "testapplication" | ||
aExp := s.mockApplicationClient.EXPECT() | ||
|
||
aExp.DestroyApplications(gomock.Any()).Return([]params.DestroyApplicationResult{{ | ||
Info: nil, Error: nil, | ||
}}, nil) | ||
|
||
infoResult := params.ApplicationInfoResult{ | ||
Result: ¶ms.ApplicationResult{ | ||
Life: "dying", | ||
}, | ||
Error: nil, | ||
} | ||
aExp.ApplicationsInfo(gomock.Any()).Return([]params.ApplicationInfoResult{infoResult}, nil) | ||
|
||
aExp.ApplicationsInfo(gomock.Any()).Return([]params.ApplicationInfoResult{{ | ||
Error: ¶ms.Error{Message: `application "testapplication" not found`, Code: "not found"}, | ||
}}, nil) | ||
|
||
client := s.getApplicationsClient() | ||
err := client.DestroyApplication(context.Background(), | ||
&DestroyApplicationInput{ | ||
ApplicationName: appName, | ||
ModelName: s.testModelName, | ||
}) | ||
s.Require().NoError(err) | ||
} | ||
|
||
// In order for 'go test' to run this suite, we need to create | ||
// a normal test function and pass our suite to suite.Run | ||
func TestApplicationSuite(t *testing.T) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters