mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[google|dns] Add support for get_managed_zone, with tests.
This commit is contained in:
parent
394b74390e
commit
46f7896079
3 changed files with 48 additions and 6 deletions
|
@ -11,9 +11,10 @@ module Fog
|
|||
GOOGLE_DNS_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/ndev.clouddns.readwrite)
|
||||
|
||||
request_path 'fog/google/requests/dns'
|
||||
request :list_managed_zones
|
||||
request :create_managed_zone
|
||||
request :delete_managed_zone
|
||||
request :get_managed_zone
|
||||
request :list_managed_zones
|
||||
|
||||
class Mock
|
||||
include Fog::Google::Shared
|
||||
|
|
31
lib/fog/google/requests/dns/get_managed_zone.rb
Normal file
31
lib/fog/google/requests/dns/get_managed_zone.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module DNS
|
||||
class Google
|
||||
|
||||
class Mock
|
||||
def get_managed_zone(zone_name_or_id)
|
||||
if self.data[:managed_zones][:by_name].has_key?(zone_name_or_id)
|
||||
build_excon_response(self.data[:managed_zones][:by_name][zone_name_or_id])
|
||||
elsif self.data[:managed_zones][:by_id].has_key?(zone_name_or_id)
|
||||
build_excon_response(self.data[:managed_zones][:by_id][zone_name_or_id])
|
||||
else
|
||||
raise Fog::Errors::NotFound, "The 'parameters.managedZone' resource named '#{zone_name_or_id}' does not exist."
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
def get_managed_zone(zone_name_or_id)
|
||||
api_method = @dns.managed_zones.get
|
||||
parameters = {
|
||||
'project' => @project,
|
||||
'managedZone' => zone_name_or_id,
|
||||
}
|
||||
|
||||
request(api_method, parameters)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@ Shindo.tests('Fog::DNS[:google] | managed_zone requests', ['google']) do
|
|||
|
||||
@google = Fog::DNS[:google]
|
||||
|
||||
@create_managed_zone_schema = {
|
||||
@managed_zone_schema = {
|
||||
'kind' => String,
|
||||
'id' => String,
|
||||
'creationTime' => String,
|
||||
|
@ -14,7 +14,7 @@ Shindo.tests('Fog::DNS[:google] | managed_zone requests', ['google']) do
|
|||
|
||||
@list_managed_zones_schema = {
|
||||
'kind' => String,
|
||||
'managedZones' => [@create_managed_zone_schema],
|
||||
'managedZones' => [@managed_zone_schema],
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
|
@ -32,10 +32,16 @@ Shindo.tests('Fog::DNS[:google] | managed_zone requests', ['google']) do
|
|||
tests("$FOG_TEST_GOOGLE_DNS_ZONE ends with dot").pending unless zone_dns_name.end_with?('.')
|
||||
|
||||
tests("#create_managed_zone").data_matches_schema(
|
||||
@create_managed_zone_schema, {:allow_extra_keys => false}) do
|
||||
@managed_zone_schema, {:allow_extra_keys => false}) do
|
||||
@google.create_managed_zone(zone_name, zone_dns_name).body
|
||||
end
|
||||
|
||||
tests("#get_managed_zone") do
|
||||
response = @google.get_managed_zone(zone_name).body
|
||||
tests('schema').data_matches_schema(@managed_zone_schema, {:allow_extra_keys => false}) { response }
|
||||
tests('test zone present').returns(zone_name) { response['name'] }
|
||||
end
|
||||
|
||||
tests("#list_managed_zones") do
|
||||
response = @google.list_managed_zones().body
|
||||
tests('schema').data_matches_schema(@list_managed_zones_schema, {:allow_extra_keys => false}) { response }
|
||||
|
@ -51,6 +57,10 @@ Shindo.tests('Fog::DNS[:google] | managed_zone requests', ['google']) do
|
|||
tests("#delete_managed_zone").raises(Fog::Errors::NotFound) do
|
||||
@google.delete_managed_zone('zone-which-does-not-exist').body
|
||||
end
|
||||
|
||||
tests("#get_managed_zone").raises(Fog::Errors::NotFound) do
|
||||
@google.get_managed_zone('zone-which-does-not-exist').body
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue