1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[AWS|ASG] filter mocked results for describe_auto_scaling_policies

This is the same issue as was fixed for ASGs in #2040 / de274452

Because Policies#get uses this method to fetch a single Policy, it was
always returning the first Policy in the data set, not the one that
actually matched the specified Policy name. Likewise, providing a filter
for `AutoScalingGroupName` did not actually filter the returned data
from this call when mocked.
This commit is contained in:
Blake Gentry 2013-08-07 17:00:08 -07:00
parent a86ae31029
commit 4245cc85f8

View file

@ -76,7 +76,21 @@ module Fog
def describe_policies(options = {})
results = { 'ScalingPolicies' => [] }
self.data[:scaling_policies].each do |asp_name, asp_data|
policy_set = self.data[:scaling_policies]
for opt_key, opt_value in options
if opt_key == "PolicyNames" && opt_value != nil && opt_value != ""
policy_set = policy_set.reject do |asp_name, asp_data|
![*options["PolicyNames"]].include?(asp_name)
end
elsif opt_key == "AutoScalingGroupName" && opt_value != nil && opt_value != ""
policy_set = policy_set.reject do |asp_name, asp_data|
options["AutoScalingGroupName"] != asp_data["AutoScalingGroupName"]
end
end
end
policy_set.each do |asp_name, asp_data|
results['ScalingPolicies'] << {
'PolicyName' => asp_name
}.merge!(asp_data)