Skip to content

Commit

Permalink
Merge pull request #592 from kayac/fix/add-test-for-591
Browse files Browse the repository at this point in the history
Add tests for #591
  • Loading branch information
fujiwara authored Jul 19, 2023
2 parents 17d7d14 + f041e3e commit 543927b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,46 @@ func TestServiceDefinitionDiffer(t *testing.T) {
t.Error("failed to SortTaskDefinitionForDiff", diff)
}
}

var testServiceDefinitionNoDesiredCount = &ecspresso.Service{
Service: types.Service{
LaunchType: types.LaunchTypeFargate,
},
DesiredCount: nil,
}

var testServiceDefinitionHasDesiredCount = &ecspresso.Service{
Service: types.Service{
LaunchType: types.LaunchTypeFargate,
},
DesiredCount: ptr(int32(2)),
}

func TestDiffServices(t *testing.T) {
t.Run("when local.DesiredCount is nil, ignore diff of DesiredCount", func (t *testing.T) {
diff, err := ecspresso.DiffServices(
testServiceDefinitionNoDesiredCount,
testServiceDefinitionHasDesiredCount,
"arn", "file", true,
)
if err != nil {
t.Error(err)
}
if diff != "" {
t.Errorf("unexpected diff: %s", diff)
}
})
t.Run("when local.DesiredCount is not nil, detect diff of DesiredCount.", func(t *testing.T) {
diff, err := ecspresso.DiffServices(
testServiceDefinitionHasDesiredCount,
testServiceDefinitionNoDesiredCount,
"arn", "file", true,
)
if err != nil {
t.Error(err)
}
if diff == "" {
t.Errorf("unexpected diff: %s", diff)
}
})
}
1 change: 1 addition & 0 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
InitVerifyState = initVerifyState
VerifyResource = verifyResource
Map2str = map2str
DiffServices = diffServices
)

type ModifyAutoScalingParams = modifyAutoScalingParams
Expand Down

0 comments on commit 543927b

Please sign in to comment.