@@ -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 ,
@@ -372,7 +370,7 @@ func TestMonitor_DrainTasks_Errors(t *testing.T) {
372370 SQS : sqsMock ,
373371 EC2 : ec2Mock ,
374372 ManagedTag : "aws-node-termination-handler/managed" ,
375- ASG : mockIsManagedTrue ( & asgMock ) ,
373+ ASG : asgMock ,
376374 CheckIfManaged : true ,
377375 QueueURL : "https://test-queue" ,
378376 InterruptionChan : drainChan ,
@@ -425,7 +423,7 @@ func TestMonitor_DrainTasksASGFailure(t *testing.T) {
425423 SQS : sqsMock ,
426424 EC2 : ec2Mock ,
427425 ManagedTag : "aws-node-termination-handler/managed" ,
428- ASG : mockIsManagedTrue ( & asgMock ) ,
426+ ASG : asgMock ,
429427 CheckIfManaged : true ,
430428 QueueURL : "https://test-queue" ,
431429 InterruptionChan : drainChan ,
@@ -703,7 +701,6 @@ func TestMonitor_EC2NoDNSName(t *testing.T) {
703701 SQS : sqsMock ,
704702 EC2 : ec2Mock ,
705703 ManagedTag : "aws-node-termination-handler/managed" ,
706- ASG : mockIsManagedTrue (nil ),
707704 CheckIfManaged : true ,
708705 QueueURL : "https://test-queue" ,
709706 InterruptionChan : drainChan ,
@@ -743,7 +740,6 @@ func TestMonitor_EC2NoDNSNameOnTerminatedInstance(t *testing.T) {
743740 SQS : sqsMock ,
744741 EC2 : ec2Mock ,
745742 ManagedTag : "aws-node-termination-handler/managed" ,
746- ASG : mockIsManagedTrue (nil ),
747743 CheckIfManaged : true ,
748744 QueueURL : "https://test-queue" ,
749745 InterruptionChan : drainChan ,
@@ -781,7 +777,6 @@ func TestMonitor_SQSDeleteFailure(t *testing.T) {
781777 SQS : sqsMock ,
782778 EC2 : ec2Mock ,
783779 ManagedTag : "aws-node-termination-handler/managed" ,
784- ASG : mockIsManagedTrue (nil ),
785780 CheckIfManaged : true ,
786781 QueueURL : "https://test-queue" ,
787782 InterruptionChan : drainChan ,
@@ -819,7 +814,6 @@ func TestMonitor_InstanceNotManaged(t *testing.T) {
819814 sqsMonitor := sqsevent.SQSMonitor {
820815 SQS : sqsMock ,
821816 EC2 : ec2Mock ,
822- ASG : mockIsManagedFalse (nil ),
823817 CheckIfManaged : true ,
824818 QueueURL : "https://test-queue" ,
825819 InterruptionChan : drainChan ,
@@ -875,30 +869,3 @@ func getSQSMessageFromEvent(event sqsevent.EventBridgeEvent) (sqs.Message, error
875869 eventStr := string (eventBytes )
876870 return sqs.Message {Body : & eventStr }, nil
877871}
878-
879- func mockIsManagedTrue (asg * h.MockedASG ) h.MockedASG {
880- if asg == nil {
881- asg = & h.MockedASG {}
882- }
883- asg .DescribeAutoScalingInstancesResp = autoscaling.DescribeAutoScalingInstancesOutput {
884- AutoScalingInstances : []* autoscaling.InstanceDetails {
885- {AutoScalingGroupName : aws .String ("test-asg" )},
886- },
887- }
888- asg .DescribeTagsPagesResp = autoscaling.DescribeTagsOutput {
889- Tags : []* autoscaling.TagDescription {
890- {Key : aws .String ("aws-node-termination-handler/managed" )},
891- },
892- }
893- return * asg
894- }
895-
896- func mockIsManagedFalse (asg * h.MockedASG ) h.MockedASG {
897- if asg == nil {
898- asg = & h.MockedASG {}
899- }
900- asg .DescribeAutoScalingInstancesResp = autoscaling.DescribeAutoScalingInstancesOutput {
901- AutoScalingInstances : []* autoscaling.InstanceDetails {},
902- }
903- return * asg
904- }
0 commit comments