Support multiple lifecycle hooks for the same ASG in our mocks

This commit is contained in:
Ole Markus With 2022-08-18 19:47:39 +02:00
parent 3ace7fd47d
commit cdea136e64
1 changed files with 8 additions and 6 deletions

View File

@ -358,7 +358,8 @@ func (m *MockAutoscaling) PutLifecycleHook(input *autoscaling.PutLifecycleHookIn
if m.LifecycleHooks == nil {
m.LifecycleHooks = make(map[string]*autoscaling.LifecycleHook)
}
m.LifecycleHooks[*hook.AutoScalingGroupName] = hook
name := *input.AutoScalingGroupName + "::" + *input.LifecycleHookName
m.LifecycleHooks[name] = hook
return &autoscaling.PutLifecycleHookOutput{}, nil
}
@ -367,13 +368,14 @@ func (m *MockAutoscaling) DescribeLifecycleHooks(input *autoscaling.DescribeLife
m.mutex.Lock()
defer m.mutex.Unlock()
name := *input.AutoScalingGroupName
response := &autoscaling.DescribeLifecycleHooksOutput{}
for _, lifecycleHookName := range input.LifecycleHookNames {
name := *input.AutoScalingGroupName + "::" + *lifecycleHookName
hook := m.LifecycleHooks[name]
if hook == nil {
return response, nil
hook := m.LifecycleHooks[name]
if hook != nil {
response.LifecycleHooks = append(response.LifecycleHooks, hook)
}
}
response.LifecycleHooks = []*autoscaling.LifecycleHook{hook}
return response, nil
}