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

fix some mocking behavior

This commit is contained in:
Eugene Howe 2016-10-10 08:46:46 -04:00
parent fba07bb064
commit 824c271ae4
3 changed files with 15 additions and 7 deletions

View file

@ -29,6 +29,8 @@ module Fog
request :modify_mount_target_security_groups
class Mock
include Fog::AWS::CredentialFetcher::ConnectionMethods
def self.data
@data ||= Hash.new do |hash, region|
hash[region] = Hash.new do |region_hash, key|
@ -56,7 +58,13 @@ module Fog
attr_accessor :region
def initialize(options={})
@region = options[:region] || "us-east-1"
@region = options[:region] || "us-east-1"
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
end
def mock_compute
@mock_compute ||= Fog::Compute::AWS.new(:aws_access_key_id => @aws_access_key_id, :aws_secret_access_key => @aws_secret_access_key, :region => @region)
end
end

View file

@ -24,9 +24,9 @@ module Fog
class Mock
def create_mount_target(file_system_id, subnet_id, options={})
response = Excon::Response.new
default_security_group = Fog::Compute[:aws].security_groups.detect { |sg| sg.description == "default group" }
security_groups = options["SecurityGroups"] || [default_security_group.group_id]
response = Excon::Response.new
default_security_group = mock_compute.security_groups.detect { |sg| sg.description == 'default group' }
security_groups = options["SecurityGroups"] || [default_security_group.group_id]
unless file_system = self.data[:file_systems][file_system_id]
raise Fog::AWS::EFS::NotFound.new("invalid file system ID: #{file_system_id}")
@ -37,12 +37,12 @@ module Fog
raise Fog::AWS::EFS::IncorrectFileSystemLifeCycleState.new("")
end
unless subnet = Fog::Compute[:aws].subnets.get(subnet_id)
unless subnet = mock_compute.subnets.get(subnet_id)
raise Fog::AWS::EFS::InvalidSubnet.new("invalid subnet ID: #{subnet_id}")
end
security_groups.each do |sg|
raise Fog::AWS::EFS::NotFound.new("invalid security group ID: #{sg}") unless Fog::Compute[:aws].data[:security_groups].values.detect { |sgd| sgd["groupId"] == sg }
raise Fog::AWS::EFS::NotFound.new("invalid security group ID: #{sg}") unless mock_compute.data[:security_groups].values.detect { |sgd| sgd["groupId"] == sg }
end
id = "fsmt-#{Fog::Mock.random_letters(8)}"

View file

@ -25,7 +25,7 @@ module Fog
end
security_groups.each do |sg|
raise Fog::AWS::EFS::NotFound.new("invalid security group ID: #{sg}") unless Fog::Compute[:aws].data[:security_groups].values.detect { |sgd| sgd["groupId"] == sg }
raise Fog::AWS::EFS::NotFound.new("invalid security group ID: #{sg}") unless mock_compute.data[:security_groups].values.detect { |sgd| sgd["groupId"] == sg }
end
self.data[:security_groups][id] = security_groups