@@ -148,7 +148,7 @@ func TestMonitor_EventBridgeSuccess(t *testing.T) {
148148 SQS : sqsMock ,
149149 EC2 : ec2Mock ,
150150 ManagedTag : "aws-node-termination-handler/managed" ,
151- ASG : mockIsManagedTrue ( nil ) ,
151+ ASG : & h. MockedASG {} ,
152152 CheckIfManaged : true ,
153153 QueueURL : "https://test-queue" ,
154154 InterruptionChan : drainChan ,
@@ -192,7 +192,6 @@ func TestMonitor_EventBridgeTestNotification(t *testing.T) {
192192 SQS : sqsMock ,
193193 EC2 : ec2Mock ,
194194 ManagedTag : "aws-node-termination-handler/managed" ,
195- ASG : mockIsManagedFalse (nil ),
196195 CheckIfManaged : true ,
197196 QueueURL : "https://test-queue" ,
198197 InterruptionChan : drainChan ,
@@ -233,7 +232,7 @@ func TestMonitor_AsgDirectToSqsSuccess(t *testing.T) {
233232 SQS : sqsMock ,
234233 EC2 : ec2Mock ,
235234 ManagedTag : "aws-node-termination-handler/managed" ,
236- ASG : mockIsManagedTrue ( nil ) ,
235+ ASG : & h. MockedASG {} ,
237236 CheckIfManaged : true ,
238237 QueueURL : "https://test-queue" ,
239238 InterruptionChan : drainChan ,
@@ -279,7 +278,6 @@ func TestMonitor_AsgDirectToSqsTestNotification(t *testing.T) {
279278 SQS : sqsMock ,
280279 EC2 : ec2Mock ,
281280 ManagedTag : "aws-node-termination-handler/managed" ,
282- ASG : mockIsManagedFalse (nil ),
283281 CheckIfManaged : true ,
284282 QueueURL : "https://test-queue" ,
285283 InterruptionChan : drainChan ,
@@ -323,7 +321,7 @@ func TestMonitor_DrainTasks(t *testing.T) {
323321 SQS : sqsMock ,
324322 EC2 : ec2Mock ,
325323 ManagedTag : "aws-node-termination-handler/managed" ,
326- ASG : mockIsManagedTrue ( & asgMock ) ,
324+ ASG : asgMock ,
327325 CheckIfManaged : true ,
328326 QueueURL : "https://test-queue" ,
329327 InterruptionChan : drainChan ,
@@ -368,7 +366,7 @@ func TestMonitor_DrainTasks_Delay(t *testing.T) {
368366 SQS : sqsMock ,
369367 EC2 : ec2Mock ,
370368 ManagedTag : "aws-node-termination-handler/managed" ,
371- ASG : mockIsManagedTrue ( & asgMock ) ,
369+ ASG : asgMock ,
372370 CheckIfManaged : true ,
373371 QueueURL : "https://test-queue" ,
374372 InterruptionChan : drainChan ,
@@ -417,7 +415,7 @@ func TestMonitor_DrainTasks_Errors(t *testing.T) {
417415 SQS : sqsMock ,
418416 EC2 : ec2Mock ,
419417 ManagedTag : "aws-node-termination-handler/managed" ,
420- ASG : mockIsManagedTrue ( & asgMock ) ,
418+ ASG : asgMock ,
421419 CheckIfManaged : true ,
422420 QueueURL : "https://test-queue" ,
423421 InterruptionChan : drainChan ,
@@ -470,7 +468,7 @@ func TestMonitor_DrainTasksASGFailure(t *testing.T) {
470468 SQS : sqsMock ,
471469 EC2 : ec2Mock ,
472470 ManagedTag : "aws-node-termination-handler/managed" ,
473- ASG : mockIsManagedTrue ( & asgMock ) ,
471+ ASG : asgMock ,
474472 CheckIfManaged : true ,
475473 QueueURL : "https://test-queue" ,
476474 InterruptionChan : drainChan ,
@@ -748,7 +746,6 @@ func TestMonitor_EC2NoDNSName(t *testing.T) {
748746 SQS : sqsMock ,
749747 EC2 : ec2Mock ,
750748 ManagedTag : "aws-node-termination-handler/managed" ,
751- ASG : mockIsManagedTrue (nil ),
752749 CheckIfManaged : true ,
753750 QueueURL : "https://test-queue" ,
754751 InterruptionChan : drainChan ,
@@ -788,7 +785,6 @@ func TestMonitor_EC2NoDNSNameOnTerminatedInstance(t *testing.T) {
788785 SQS : sqsMock ,
789786 EC2 : ec2Mock ,
790787 ManagedTag : "aws-node-termination-handler/managed" ,
791- ASG : mockIsManagedTrue (nil ),
792788 CheckIfManaged : true ,
793789 QueueURL : "https://test-queue" ,
794790 InterruptionChan : drainChan ,
@@ -826,7 +822,6 @@ func TestMonitor_SQSDeleteFailure(t *testing.T) {
826822 SQS : sqsMock ,
827823 EC2 : ec2Mock ,
828824 ManagedTag : "aws-node-termination-handler/managed" ,
829- ASG : mockIsManagedTrue (nil ),
830825 CheckIfManaged : true ,
831826 QueueURL : "https://test-queue" ,
832827 InterruptionChan : drainChan ,
@@ -864,7 +859,6 @@ func TestMonitor_InstanceNotManaged(t *testing.T) {
864859 sqsMonitor := sqsevent.SQSMonitor {
865860 SQS : sqsMock ,
866861 EC2 : ec2Mock ,
867- ASG : mockIsManagedFalse (nil ),
868862 CheckIfManaged : true ,
869863 QueueURL : "https://test-queue" ,
870864 InterruptionChan : drainChan ,
@@ -921,30 +915,3 @@ func getSQSMessageFromEvent(event sqsevent.EventBridgeEvent) (sqs.Message, error
921915 messageId := "d7de6634-f672-ce5c-d87e-ae0b1b5b2510"
922916 return sqs.Message {Body : & eventStr , MessageId : & messageId }, nil
923917}
924-
925- func mockIsManagedTrue (asg * h.MockedASG ) h.MockedASG {
926- if asg == nil {
927- asg = & h.MockedASG {}
928- }
929- asg .DescribeAutoScalingInstancesResp = autoscaling.DescribeAutoScalingInstancesOutput {
930- AutoScalingInstances : []* autoscaling.InstanceDetails {
931- {AutoScalingGroupName : aws .String ("test-asg" )},
932- },
933- }
934- asg .DescribeTagsPagesResp = autoscaling.DescribeTagsOutput {
935- Tags : []* autoscaling.TagDescription {
936- {Key : aws .String ("aws-node-termination-handler/managed" )},
937- },
938- }
939- return * asg
940- }
941-
942- func mockIsManagedFalse (asg * h.MockedASG ) h.MockedASG {
943- if asg == nil {
944- asg = & h.MockedASG {}
945- }
946- asg .DescribeAutoScalingInstancesResp = autoscaling.DescribeAutoScalingInstancesOutput {
947- AutoScalingInstances : []* autoscaling.InstanceDetails {},
948- }
949- return * asg
950- }
0 commit comments