diff --git a/diff_test.go b/diff_test.go index 9fb5f044..93e21f15 100644 --- a/diff_test.go +++ b/diff_test.go @@ -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) + } + }) +} diff --git a/export_test.go b/export_test.go index 42e586e7..b936b6d2 100644 --- a/export_test.go +++ b/export_test.go @@ -24,6 +24,7 @@ var ( InitVerifyState = initVerifyState VerifyResource = verifyResource Map2str = map2str + DiffServices = diffServices ) type ModifyAutoScalingParams = modifyAutoScalingParams