From 8f76f79341779af2bce1fd5857756bd95058903f Mon Sep 17 00:00:00 2001 From: Eugene Howe Date: Fri, 17 Mar 2017 13:27:54 -0400 Subject: [PATCH] spec and mock fixes --- lib/fog/aws/models/compute/vpc.rb | 4 ++++ .../requests/compute/disable_vpc_classic_link_dns_support.rb | 4 +++- .../requests/compute/enable_vpc_classic_link_dns_support.rb | 4 +++- tests/requests/compute/vpc_tests.rb | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/fog/aws/models/compute/vpc.rb b/lib/fog/aws/models/compute/vpc.rb index d640fee8c..2673c190f 100644 --- a/lib/fog/aws/models/compute/vpc.rb +++ b/lib/fog/aws/models/compute/vpc.rb @@ -50,6 +50,8 @@ module Fog def classic_link_enabled? requires :identity service.describe_vpc_classic_link(:vpc_ids => [self.identity]).body['vpcSet'].first['classicLinkEnabled'] + rescue + nil end def enable_classic_link @@ -65,6 +67,8 @@ module Fog def classic_link_dns_enabled? requires :identity service.describe_vpc_classic_link_dns_support(:vpc_ids => [self.identity]).body['vpcs'].first['classicLinkDnsSupported'] + rescue + nil end def enable_classic_link_dns diff --git a/lib/fog/aws/requests/compute/disable_vpc_classic_link_dns_support.rb b/lib/fog/aws/requests/compute/disable_vpc_classic_link_dns_support.rb index e0fbebf13..110226fa2 100644 --- a/lib/fog/aws/requests/compute/disable_vpc_classic_link_dns_support.rb +++ b/lib/fog/aws/requests/compute/disable_vpc_classic_link_dns_support.rb @@ -29,7 +29,9 @@ module Fog class Mock def disable_vpc_classic_link_dns_support(vpc_id) response = Excon::Response.new - vpc = self.data[:vpcs].find { |v| v['vpcId'] == vpc_id } + unless vpc = self.data[:vpcs].find { |v| v['vpcId'] == vpc_id } + raise Fog::Compute::AWS::NotFound.new("The VPC '#{vpc_id}' does not exist") + end vpc['classicLinkDnsSupport'] = false response.body = { 'requestId' => Fog::AWS::Mock.request_id, diff --git a/lib/fog/aws/requests/compute/enable_vpc_classic_link_dns_support.rb b/lib/fog/aws/requests/compute/enable_vpc_classic_link_dns_support.rb index bc8a3b378..dab557461 100644 --- a/lib/fog/aws/requests/compute/enable_vpc_classic_link_dns_support.rb +++ b/lib/fog/aws/requests/compute/enable_vpc_classic_link_dns_support.rb @@ -29,7 +29,9 @@ module Fog class Mock def enable_vpc_classic_link_dns_support(vpc_id) response = Excon::Response.new - vpc = self.data[:vpcs].find { |v| v['vpcId'] == vpc_id } + unless vpc = self.data[:vpcs].find { |v| v['vpcId'] == vpc_id } + raise Fog::Compute::AWS::NotFound.new("The VPC '#{vpc_id}' does not exist") + end vpc['classicLinkDnsSupport'] = true response.body = { 'requestId' => Fog::AWS::Mock.request_id, diff --git a/tests/requests/compute/vpc_tests.rb b/tests/requests/compute/vpc_tests.rb index 0c2754733..10e35144a 100644 --- a/tests/requests/compute/vpc_tests.rb +++ b/tests/requests/compute/vpc_tests.rb @@ -140,7 +140,7 @@ Shindo.tests('Fog::Compute[:aws] | vpc requests', ['aws']) do tests("enable_vpc_classic_link").returns(true) do Fog::Compute[:aws].enable_vpc_classic_link @vpc_id - body = Fog::Compute[:aws].describe_vpc_classic_link(:vpc_ids => [@vpc_id]) + body = Fog::Compute[:aws].describe_vpc_classic_link(:vpc_ids => [@vpc_id]).body body['vpcSet'].first['classicLinkEnabled'] end @@ -198,7 +198,7 @@ Shindo.tests('Fog::Compute[:aws] | vpc requests', ['aws']) do tests("disable_vpc_classic_link").returns(false) do Fog::Compute[:aws].disable_vpc_classic_link @vpc_id - body = Fog::Compute[:aws].describe_vpc_classic_link(:vpc_ids => [@vpc_id]) + body = Fog::Compute[:aws].describe_vpc_classic_link(:vpc_ids => [@vpc_id]).body body['vpcSet'].first['classicLinkEnabled'] end