mirror of
https://github.com/fog/fog-aws.git
synced 2022-11-09 13:50:52 -05:00
Implement tests for ELBV2 tags
This commit is contained in:
parent
413f0a2dc8
commit
bb28bc6fb0
2 changed files with 34 additions and 6 deletions
|
@ -102,6 +102,7 @@ module Fog
|
||||||
|
|
||||||
dns_name = Fog::AWS::ELBV2::Mock.dns_name(name, @region)
|
dns_name = Fog::AWS::ELBV2::Mock.dns_name(name, @region)
|
||||||
type = options[:type] || 'application'
|
type = options[:type] || 'application'
|
||||||
|
load_balancer_arn = Fog::AWS::Mock.arn('elasticloadbalancing', self.data[:owner_id], "loadbalancer/#{type[0..2]}/#{name}/#{Fog::AWS::Mock.key_id}")
|
||||||
|
|
||||||
subnet_ids = options[:subnets] || []
|
subnet_ids = options[:subnets] || []
|
||||||
region = if subnet_ids.any?
|
region = if subnet_ids.any?
|
||||||
|
@ -126,7 +127,7 @@ module Fog
|
||||||
vpc_id = subnets.first['vpcId']
|
vpc_id = subnets.first['vpcId']
|
||||||
|
|
||||||
self.data[:tags] ||= {}
|
self.data[:tags] ||= {}
|
||||||
self.data[:tags][name] = options[:tags] || {}
|
self.data[:tags][load_balancer_arn] = options[:tags] || {}
|
||||||
|
|
||||||
load_balancer = {
|
load_balancer = {
|
||||||
'AvailabilityZones' => availability_zones || [],
|
'AvailabilityZones' => availability_zones || [],
|
||||||
|
@ -138,10 +139,10 @@ module Fog
|
||||||
'VpcId' => vpc_id,
|
'VpcId' => vpc_id,
|
||||||
'Type' => type,
|
'Type' => type,
|
||||||
'State' => {'Code' => 'provisioning'},
|
'State' => {'Code' => 'provisioning'},
|
||||||
'LoadBalancerArn' => Fog::AWS::Mock.arn('elasticloadbalancing', self.data[:owner_id], "loadbalancer/#{type[0..2]}/#{name}/#{Fog::AWS::Mock.key_id}"),
|
'LoadBalancerArn' => load_balancer_arn,
|
||||||
'LoadBalancerName' => name
|
'LoadBalancerName' => name
|
||||||
}
|
}
|
||||||
self.data[:load_balancers_v2][name] = load_balancer
|
self.data[:load_balancers_v2][load_balancer_arn] = load_balancer
|
||||||
response.body = {
|
response.body = {
|
||||||
'ResponseMetadata' => {
|
'ResponseMetadata' => {
|
||||||
'RequestId' => Fog::AWS::Mock.request_id
|
'RequestId' => Fog::AWS::Mock.request_id
|
||||||
|
|
|
@ -3,21 +3,48 @@ Shindo.tests('AWS::ELBV2 | load_balancer_tests', ['aws', 'elb']) do
|
||||||
@key_name = 'fog-test'
|
@key_name = 'fog-test'
|
||||||
vpc = Fog::Compute[:aws].create_vpc('10.255.254.64/28').body['vpcSet'].first
|
vpc = Fog::Compute[:aws].create_vpc('10.255.254.64/28').body['vpcSet'].first
|
||||||
@subnet_id = Fog::Compute[:aws].create_subnet(vpc['vpcId'], vpc['cidrBlock']).body['subnet']['subnetId']
|
@subnet_id = Fog::Compute[:aws].create_subnet(vpc['vpcId'], vpc['cidrBlock']).body['subnet']['subnetId']
|
||||||
|
@tags = { 'test1' => 'Value1', 'test2' => 'Value2' }
|
||||||
|
|
||||||
tests('success') do
|
tests('success') do
|
||||||
tests("#create_load_balancer").formats(AWS::ELBV2::Formats::CREATE_LOAD_BALANCER) do
|
tests('#create_load_balancer').formats(AWS::ELBV2::Formats::CREATE_LOAD_BALANCER) do
|
||||||
options = {
|
options = {
|
||||||
subnets: [@subnet_id]
|
subnets: [@subnet_id]
|
||||||
}
|
}
|
||||||
Fog::AWS[:elbv2].create_load_balancer(@load_balancer_id, options).body
|
load_balancer = Fog::AWS[:elbv2].create_load_balancer(@load_balancer_id, options).body
|
||||||
|
@load_balancer_arn = load_balancer['CreateLoadBalancerResult']['LoadBalancers'].first['LoadBalancerArn']
|
||||||
|
load_balancer
|
||||||
end
|
end
|
||||||
|
|
||||||
tests("#describe_load_balancers").formats(AWS::ELBV2::Formats::DESCRIBE_LOAD_BALANCERS) do
|
tests('#describe_load_balancers').formats(AWS::ELBV2::Formats::DESCRIBE_LOAD_BALANCERS) do
|
||||||
Fog::AWS[:elbv2].describe_load_balancers.body
|
Fog::AWS[:elbv2].describe_load_balancers.body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests('#describe_load_balancers with bad name') do
|
tests('#describe_load_balancers with bad name') do
|
||||||
raises(Fog::AWS::ELBV2::NotFound) { Fog::AWS[:elbv2].describe_load_balancers('LoadBalancerNames' => 'none-such-lb') }
|
raises(Fog::AWS::ELBV2::NotFound) { Fog::AWS[:elbv2].describe_load_balancers('LoadBalancerNames' => 'none-such-lb') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests("#add_tags('#{@load_balancer_arn}', #{@tags})").formats(AWS::ELBV2::Formats::BASIC) do
|
||||||
|
Fog::AWS[:elbv2].add_tags(@load_balancer_arn, @tags).body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#describe_tags').formats(AWS::ELBV2::Formats::DESCRIBE_TAGS) do
|
||||||
|
Fog::AWS[:elbv2].describe_tags(@load_balancer_arn).body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests('#describe_tags with at least one wrong arn') do
|
||||||
|
raises(Fog::AWS::ELBV2::NotFound) { Fog::AWS[:elbv2].describe_tags([@load_balancer_arn, 'wrong_arn']) }
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#describe_tags(#{@load_balancer_arn})").returns(@tags) do
|
||||||
|
Fog::AWS[:elbv2].describe_tags(@load_balancer_arn).body['DescribeTagsResult']['TagDescriptions'].first['Tags']
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#remove_tags('#{@load_balancer_arn}', #{@tags.keys})").formats(AWS::ELBV2::Formats::BASIC) do
|
||||||
|
Fog::AWS[:elbv2].remove_tags(@load_balancer_arn, @tags.keys).body
|
||||||
|
end
|
||||||
|
|
||||||
|
tests("#describe_tags(#{@load_balancer_arn})").returns({}) do
|
||||||
|
Fog::AWS[:elbv2].describe_tags(@load_balancer_arn).body['DescribeTagsResult']['TagDescriptions'].first['Tags']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue