Skip to content

Commit

Permalink
[Resolve #1143] fix "create" cmd with existing stack (#1144)
Browse files Browse the repository at this point in the history
"create" command should return 0 if stack exists
  • Loading branch information
ykhalyavin committed Nov 2, 2021
1 parent 0953d4b commit a020e68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sceptre/plan/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def create(self):
"%s - Stack already exists", self.stack.name
)

status = "COMPLETE"
status = StackStatus.COMPLETE
else:
raise

Expand Down
20 changes: 20 additions & 0 deletions tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,26 @@ def test_create_sends_correct_request_with_no_failure_no_timeout(
)
mock_wait_for_completion.assert_called_once_with()

@patch("sceptre.plan.actions.StackActions._wait_for_completion")
def test_create_stack_already_exists(
self, mock_wait_for_completion
):
self.actions.stack._template = Mock(spec=Template)
self.actions.stack._template.get_boto_call_parameter.return_value = {
"Template": sentinel.template
}
mock_wait_for_completion.side_effect = ClientError(
{
"Error": {
"Code": "AlreadyExistsException",
"Message": "Stack already [{}] exists".format(self.actions.stack.name)
}
},
sentinel.operation
)
response = self.actions.create()
assert response == StackStatus.COMPLETE

@patch("sceptre.plan.actions.StackActions._wait_for_completion")
def test_update_sends_correct_request(self, mock_wait_for_completion):
self.actions.stack._template = Mock(spec=Template)
Expand Down

0 comments on commit a020e68

Please sign in to comment.