From f867f6397cf362e92883601ff8236c3c127de150 Mon Sep 17 00:00:00 2001 From: Yusuke Yoda Date: Wed, 9 Nov 2022 16:47:16 +0900 Subject: [PATCH] Fix tests --- test/e2e_test.go | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/test/e2e_test.go b/test/e2e_test.go index 4126e8b..6d770e1 100644 --- a/test/e2e_test.go +++ b/test/e2e_test.go @@ -173,28 +173,39 @@ func TestE2E(t *testing.T) { t.Run("EC2MoveScheduledAction", func(t *testing.T) { now := time.Now() - state := NewTestingState(config).WithAutoScalingGroupScheduledAction( - "fromASG", []asgTypes.ScheduledUpdateGroupAction{ - { - AutoScalingGroupName: aws.String("fromASG"), - DesiredCapacity: aws.Int32(1), - MinSize: aws.Int32(2), - MaxSize: aws.Int32(3), - Recurrence: aws.String("1/* * * * *"), - ScheduledActionARN: aws.String("fromARN"), - ScheduledActionName: aws.String("fromAction"), - StartTime: aws.Time(now), - EndTime: aws.Time(now.Add(24 + time.Hour)), - TimeZone: aws.String(config.TimeZone.Location), - }, + scheduledActions := []asgTypes.ScheduledUpdateGroupAction{ + { + AutoScalingGroupName: aws.String("fromASG"), + DesiredCapacity: aws.Int32(1), + MinSize: aws.Int32(2), + MaxSize: aws.Int32(3), + Recurrence: aws.String("1/* * * * *"), + ScheduledActionARN: aws.String("fromARN001"), + ScheduledActionName: aws.String("fromAction001"), + StartTime: aws.Time(now), + EndTime: aws.Time(now.Add(24 + time.Hour)), + TimeZone: aws.String(config.TimeZone.Location), + }, + { + AutoScalingGroupName: aws.String("fromASG"), + DesiredCapacity: aws.Int32(1), + MinSize: aws.Int32(2), + MaxSize: aws.Int32(3), + Recurrence: aws.String("1/* * * * *"), + ScheduledActionARN: aws.String("fromARN002"), + ScheduledActionName: aws.String("fromAction002"), + StartTime: aws.Time(now), + EndTime: aws.Time(now.Add(24 + time.Hour)), + TimeZone: aws.String(config.TimeZone.Location), }, + } + state := NewTestingState(config).WithAutoScalingGroupScheduledAction( + "fromASG", scheduledActions, "toASG", []asgTypes.ScheduledUpdateGroupAction{}, ) deployer := internal.NewDeployer(config, NewMockAwsClient(state), logger) - assert.Success(t, deployer.MoveScheduledActions(ctx, "fromASG", "toASG")) - assert.Equal(t, len(state.GetAutoScalingGroup("fromASG").ScheduledActions), 0) - assert.Equal(t, len(state.GetAutoScalingGroup("toASG").ScheduledActions), 1) + assert.Equal(t, len(state.GetAutoScalingGroup("toASG").ScheduledActions), len(scheduledActions)) }) }