mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[google|compute] Change how get_region works for mocks.
This commit is contained in:
parent
0cdf27d59a
commit
baffd91136
2 changed files with 15 additions and 8 deletions
|
@ -2,13 +2,21 @@ module Fog
|
|||
module Compute
|
||||
class Google
|
||||
class Mock
|
||||
def get_region(identity)
|
||||
identity = identity.split('/')[-1]
|
||||
regions = Fog::Compute[:google].list_regions
|
||||
region = regions.body['items'].select { |region| region['name'] == identity }
|
||||
|
||||
raise Fog::Errors::NotFound if region.nil? || region.empty?
|
||||
build_excon_response(region.first)
|
||||
def get_region(region_name)
|
||||
region = self.data[:regions][region_name] || {
|
||||
"error" => {
|
||||
"errors" => [
|
||||
{
|
||||
"domain" => "global",
|
||||
"reason" => "notFound",
|
||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}' was not found"
|
||||
}
|
||||
],
|
||||
"code" => 404,
|
||||
"message" => "The resource 'projects/#{project}/regions/#{region_name}' was not found"
|
||||
}
|
||||
}
|
||||
build_excon_response(region)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,5 +5,4 @@ Shindo.tests("Fog::Compute[:google] | target pools model", ['google']) do
|
|||
instance = create_test_server(Fog::Compute[:google], 'us-central1-a')
|
||||
health_check = create_test_http_health_check(Fog::Compute[:google])
|
||||
collection_tests(Fog::Compute[:google].target_pools, {:name => "fog-test-target-pool-#{random_string}", :region => region, :instances => [instance.self_link], :healthChecks => [health_check.self_link]})
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue