Skip to content

Commit

Permalink
Add test case for rolling in progress stacks
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Abdelrahman <mustafa.abdelrahman@zalando.de>
  • Loading branch information
MustafaSaber committed Jan 2, 2024
1 parent 076881a commit df5a8fa
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
35 changes: 35 additions & 0 deletions aws/cf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,41 @@ func TestFindManagedStacks(t *testing.T) {
},
wantErr: false,
},
{
name: "successfull-call-with-rollback-status",
given: fake.CFOutputs{
DescribeStackPages: fake.R(nil, nil),
DescribeStacks: fake.R(&cloudformation.DescribeStacksOutput{
Stacks: []*cloudformation.Stack{
{
StackName: aws.String("managed-stack-rolling-back"),
StackStatus: aws.String(cloudformation.StackStatusRollbackInProgress),
Tags: []*cloudformation.Tag{
cfTag(kubernetesCreatorTag, DefaultControllerID),
cfTag(clusterIDTagPrefix+"test-cluster", resourceLifecycleOwned),
cfTag(certificateARNTagPrefix+"cert-arn", time.Time{}.Format(time.RFC3339)),
},
Outputs: []*cloudformation.Output{},
},
},
}, nil),
},
want: []*Stack{
{
Name: "managed-stack-rolling-back",
CertificateARNs: map[string]time.Time{
"cert-arn": {},
},
tags: map[string]string{
kubernetesCreatorTag: DefaultControllerID,
clusterIDTagPrefix + "test-cluster": resourceLifecycleOwned,
certificateARNTagPrefix + "cert-arn": time.Time{}.Format(time.RFC3339),
},
status: cloudformation.StackStatusRollbackInProgress,
HTTP2: true,
},
},
},
{
name: "no-ready-stacks",
given: fake.CFOutputs{
Expand Down
15 changes: 15 additions & 0 deletions aws/fake/cf.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type CFOutputs struct {
CreateStack *APIResponse
UpdateStack *APIResponse
DeleteStack *APIResponse
RollbackStack *APIResponse
UpdateTerminationProtection *APIResponse
}

Expand Down Expand Up @@ -122,3 +123,17 @@ func (m *CFClient) UpdateTerminationProtection(params *cloudformation.UpdateTerm
}
return out, m.Outputs.UpdateTerminationProtection.err
}

func (m *CFClient) RollbackStack(params *cloudformation.RollbackStackInput) (*cloudformation.RollbackStackOutput, error) {
out, ok := m.Outputs.RollbackStack.response.(*cloudformation.RollbackStackOutput)
if !ok {
return nil, m.Outputs.RollbackStack.err
}
return out, m.Outputs.RollbackStack.err
}

func MockRollbackStackOutput(stackId string) *cloudformation.RollbackStackOutput {
return &cloudformation.RollbackStackOutput{
StackId: aws.String(stackId),
}
}

0 comments on commit df5a8fa

Please sign in to comment.