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

added tests for list requests

This commit is contained in:
snyquist2 2014-08-07 00:58:55 +00:00
parent 072b8b4e97
commit 6ab12ee6f2
23 changed files with 79 additions and 29 deletions

View file

@ -9,8 +9,8 @@ module Fog
GOOGLE_COMPUTE_API_VERSION = 'v1'
GOOGLE_COMPUTE_BASE_URL = 'https://www.googleapis.com/compute/'
GOOGLE_COMPUTE_API_SCOPE_URLS = %w(https://www.googleapis.com/auth/compute
https://www.googleapis.com/auth/devstorage.read_write
https://www.googleapis.com/auth/ndev.cloudman
https://www.googleapis.com/auth/devstorage.read_write
https://www.googleapis.com/auth/ndev.cloudman
https://www.googleapis.com/auth/cloud-platform)
GOOGLE_COMPUTE_DEFAULT_NETWORK = 'default'
@ -385,7 +385,7 @@ module Fog
"name" => "test-backend-service",
"description" => '',
"backends" => [
{
{
"description" => '',
"group" => "https://www.googleapis.com/resourceviews/v1beta1/projects#{@project}/zones/us-central1-a/zoneViews/name",
"balancingMode" => "RATE",

View file

@ -8,7 +8,7 @@ module Fog
model Fog::Compute::Google::BackendService
def all(filters={})
data = service.list_backend_services.body['items'].values || []
data = service.list_backend_services.body['items'] || []
load(data)
end

View file

@ -8,7 +8,7 @@ module Fog
model Fog::Compute::Google::GlobalForwardingRule
def all
data = service.list_global_forwarding_rules.body['items'].values || []
data = service.list_global_forwarding_rules.body['items'] || []
load(data)
end

View file

@ -8,7 +8,7 @@ module Fog
model Fog::Compute::Google::TargetHttpProxy
def all(filters={})
data = service.list_target_http_proxies.body['items'].values || []
data = service.list_target_http_proxies.body['items'] || []
load(data)
end

View file

@ -8,7 +8,7 @@ module Fog
model Fog::Compute::Google::UrlMap
def all
data = service.list_url_maps.body['items'].values || []
data = service.list_url_maps.body['items'] || []
load(data)
end
@ -20,5 +20,3 @@ module Fog
end
end
end

View file

@ -1,4 +1,3 @@
module Fog
module Compute
class Google
@ -25,4 +24,3 @@ module Fog
end
end
end

View file

@ -3,7 +3,7 @@ module Fog
class Google
class Mock
def list_backend_services
backend_services = self.data[:backend_services]
backend_services = self.data[:backend_services].values
build_excon_response({
"kind" => "compute#backendServiceList",

View file

@ -3,7 +3,7 @@ module Fog
class Google
class Mock
def list_global_forwarding_rules(region_name = 'global')
global_forwarding_rules = self.data[:global_forwarding_rules]
global_forwarding_rules = self.data[:global_forwarding_rules].values
build_excon_response({
"kind" => "compute#forwardingRuleList",

View file

@ -3,7 +3,7 @@ module Fog
class Google
class Mock
def list_target_http_proxies
proxies = self.data[:target_http_proxies]
proxies = self.data[:target_http_proxies].values
build_excon_response({
"kind" => "compute#targetHttpProxyList",

View file

@ -3,7 +3,7 @@ module Fog
class Google
class Mock
def list_url_maps
url_maps = self.data[:url_maps]
url_maps = self.data[:url_maps].values
build_excon_response({
"kind" => "compute#urlMapList",

View file

@ -4,6 +4,7 @@ Shindo.tests('Fog::DNS[:dnsimple] | DNS requests', ['dnsimple', 'dns']) do
@domain_count = 0
tests("success") do
test("get current domain count") do
response = Fog::DNS[:dnsimple].list_domains()
if response.status == 200

View file

@ -20,7 +20,6 @@ def create_test_http_health_check(connection)
health_check = connection.http_health_checks.create({
:name => "fog-test-check-#{random_string}"
})
#health_check.wait_for { ready? }
health_check
end
@ -45,7 +44,6 @@ end
def create_test_server(connection, zone)
random_string = SecureRandom.hex
disk = create_test_disk(connection,zone)
server = connection.servers.create({
:name => "fog-test-server-#{random_string}",
:disks => [disk],
@ -65,7 +63,6 @@ end
def create_test_zone_view(connection, zone)
random_string = SecureRandom.hex
zone_view = connection.zone_views.create({
:name => "fog-test-zone-view-#{random_string}",
:zone => zone

View file

@ -1,7 +1,7 @@
require 'securerandom'
Shindo.tests("Fog::Compute[:google] | global forwarding rule model", ['google']) do
random_string = SecureRandom.hex
proxy = create_test_target_http_proxy(Fog::Compute[:google])
proxy = create_test_target_http_proxy(Fog::Compute[:google])
model_tests(Fog::Compute[:google].global_forwarding_rules, {:name => 'fog-test-global-forwarding-rule-#{random_string}', :target => proxy.self_link})
end

View file

@ -1,5 +1,5 @@
Shindo.tests("Fog::Compute[:google] | global forwarding rules model", ['google']) do
proxy = create_test_target_http_proxy(Fog::Compute[:google])
proxy = create_test_target_http_proxy(Fog::Compute[:google])
collection_tests(Fog::Compute[:google].global_forwarding_rules, {:name => 'fog-test-global-forwarding-rule-#{random_string}', :target => proxy.self_link})
end

View file

@ -1,6 +1,6 @@
require 'securerandom'
Shindo.tests("Fog::Compute[:google] | target HTTP proxy model", ['google']) do
random_string = SecureRandom.hex
url_map = create_test_url_map(Fog::Compute[:google])
url_map = create_test_url_map(Fog::Compute[:google])
model_tests(Fog::Compute[:google].target_http_proxies, {:name => 'fog-test-target-http-proxy-#{random_string}', :urlMap => url_map.self_link})
end

View file

@ -1,5 +1,5 @@
Shindo.tests("Fog::Compute[:google] | target instances model", ['google']) do
@zone= 'us-central1-a'
instance = create_test_server(Fog::Compute[:google], @zone)
instance = create_test_server(Fog::Compute[:google], @zone)
collection_tests(Fog::Compute[:google].target_instances, {:name => 'fog-test-target-instances', :instance => instance.self_link, :zone => @zone})
end

View file

@ -45,6 +45,13 @@ Shindo.tests('Fog::Compute[:google] | backend services requests', ['google']) do
'operationType' => String
}
@list_backend_services_format = {
'kind' => String,
'selfLink' => String,
'id' => String,
'items' => Array
}
tests('success') do
backend_service_name = 'test-backend-service'
@ -59,6 +66,10 @@ Shindo.tests('Fog::Compute[:google] | backend services requests', ['google']) do
response
end
tests("#list_backend_services").formats(@list_backend_services_format) do
@google.list_backend_services.body
end
tests("#get_backend_service").formats(@get_backend_service_format) do
@google.get_backend_service(backend_service_name).body
end

View file

@ -46,6 +46,13 @@ Shindo.tests('Fog::Compute[:google] | global forwarding rule requests', ['google
'operationType' => String
}
@list_global_forwarding_rules_format = {
'kind' => String,
'id' => String,
'items' => Array,
'selfLink' => String
}
tests('success') do
global_forwarding_rule_name = 'test-global-forwarding-rule'
@ -63,6 +70,10 @@ Shindo.tests('Fog::Compute[:google] | global forwarding rule requests', ['google
@google.get_global_forwarding_rule(global_forwarding_rule_name).body
end
tests("#list_global_forwarding_rules").formats(@list_global_forwarding_rules_format) do
@google.list_global_forwarding_rules('global').body
end
tests("#delete_global_forwarding_rule").formats(@delete_global_forwarding_rule_format) do
@google.delete_global_forwarding_rule(global_forwarding_rule_name).body
end

View file

@ -42,6 +42,13 @@ Shindo.tests('Fog::Compute[:google] | target HTTP proxy requests', ['google']) d
'operationType' => String
}
@list_target_http_proxies_format = {
'kind' => String,
'selfLink' => String,
'id' => String,
'items' => Array
}
tests('success') do
target_http_proxy_name = 'test-target-http-proxy'
@ -59,6 +66,10 @@ Shindo.tests('Fog::Compute[:google] | target HTTP proxy requests', ['google']) d
@google.get_target_http_proxy(target_http_proxy_name).body
end
tests("#list_target_http_proxies").formats(@list_target_http_proxies_format) do
@google.list_target_http_proxies.body
end
tests("#delete_target_http_proxy").formats(@delete_target_http_proxy_format) do
@google.delete_target_http_proxy(target_http_proxy_name).body
end

View file

@ -45,6 +45,13 @@ Shindo.tests('Fog::Compute[:google] | target instance requests', ['google']) do
'operationType' => String
}
@list_target_instances_format = {
'kind' => String,
'id' => String,
'selfLink' => String,
'items' => Array
}
tests('success') do
target_instance_name = 'test-target_instance'
@ -63,6 +70,10 @@ Shindo.tests('Fog::Compute[:google] | target instance requests', ['google']) do
@google.get_target_instance(target_instance_name, @zone).body
end
tests("#list_target_instances").formats(@list_target_instances_format) do
@google.list_target_instances(@zone).body
end
tests("#delete_target_instance").formats(@delete_target_instance_format) do
@google.delete_target_instance(target_instance_name, @zone).body
end

View file

@ -45,6 +45,13 @@ Shindo.tests('Fog::Compute[:google] | url map requests', ['google']) do
'operationType' => String
}
@list_url_maps_format = {
'kind' => String,
'id' => String,
'selfLink' => String,
'items' => Array
}
tests('success') do
url_map_name = 'test-url-map'
@ -62,6 +69,10 @@ Shindo.tests('Fog::Compute[:google] | url map requests', ['google']) do
@google.get_url_map(url_map_name).body
end
tests("#list_url_maps").formats(@list_url_maps_format) do
@google.list_url_maps.body
end
tests("#delete_url_map").formats(@delete_url_map_format) do
@google.delete_url_map(url_map_name).body
end

View file

@ -1,5 +1,6 @@
def collection_tests(collection, params = {}, mocks_implemented = true)
tests('success') do
tests("#new(#{params.inspect})").succeeds do
pending if Fog.mocking? && !mocks_implemented
collection.new(params)
@ -10,25 +11,25 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
@instance = collection.create(params)
end
# FIXME: work around for timing issue on AWS describe_instances mocks
if Fog.mocking? && @instance.respond_to?(:ready?)
@instance.wait_for { ready? }
end
tests("#all").succeeds do
pending if Fog.mocking? && !mocks_implemented
collection.all
end
if !Fog.mocking? || mocks_implemented
@identity = @instance.identity
end
tests("#get(#{@identity})").succeeds do
pending if Fog.mocking? && !mocks_implemented
collection.get(@identity)
end
tests('Enumerable') do
pending if Fog.mocking? && !mocks_implemented
@ -43,7 +44,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
if RUBY_PLATFORM == "java" and JRUBY_VERSION =~ /1\.7\.[5-8]/
methods.delete('all?')
end
methods.each do |enum_method|
if collection.respond_to?(enum_method)
tests("##{enum_method}").succeeds do

View file

@ -7,7 +7,7 @@ def model_tests(collection, params = {}, mocks_implemented = true)
pending if Fog.mocking? && !mocks_implemented
@instance.save
end
if block_given?
yield(@instance)
end