Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/pkg/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ func (c Client) serviceARN(app, env, svc string) (*ecs.ServiceArn, error) {
if len(activeSvcs) > 1 {
return nil, fmt.Errorf("more than one ECS service with tags %s", tags.String())
}
if len(activeSvcs) == 0 {
return nil, fmt.Errorf("no active ECS service found")
}
serviceARN, err := ecs.ParseServiceArn(activeSvcs[0])
if err != nil {
return nil, fmt.Errorf("parse service arn: %w", err)
Expand Down
17 changes: 17 additions & 0 deletions internal/pkg/ecs/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,23 @@ func TestClient_serviceARN(t *testing.T) {
},
wantedError: fmt.Errorf(`more than one ECS service with tags "copilot-application"="mockApp","copilot-environment"="mockEnv","copilot-service"="mockSvc"`),
},
"error if there is no active svc": {
setupMocks: func(m clientMocks) {
gomock.InOrder(
m.resourceGetter.EXPECT().GetResourcesByTags(serviceResourceType, getRgInput).
Return([]*resourcegroups.Resource{
{ARN: mockSvcARN1}, {ARN: mockSvcARN2},
}, nil),
m.resourceGetter.EXPECT().GetResourcesByTags(clusterResourceType, getRgEnvClusterInput).
Return([]*resourcegroups.Resource{
{ARN: "mockARN1"}, {ARN: "mockARN2"},
}, nil),
m.ecsClient.EXPECT().ActiveClusters("mockARN1", "mockARN2").Return([]string{"mockARN1"}, nil),
m.ecsClient.EXPECT().ActiveServices("mockARN1", []string{mockSvcARN1, mockSvcARN2}).Return([]string{}, nil),
)
},
wantedError: fmt.Errorf(`no active ECS service found`),
},
"success with only one active svc": {
setupMocks: func(m clientMocks) {
gomock.InOrder(
Expand Down