From e9a49903b2b258e1caa621b680587db930e370f5 Mon Sep 17 00:00:00 2001 From: Isaac Hollander McCreery Date: Mon, 8 Jun 2015 17:11:21 +0000 Subject: [PATCH] [shindo-minitest] convert GlobalForwardingRules tests to minitest, including a few bug fixes in the implementation of GlobalForwardingRules --- .../models/compute/global_forwarding_rules.rb | 8 +++++--- .../compute/test_global_forwarding_rules.rb | 11 +++++++++++ .../global_forwarding_rules_factory.rb | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 test/integration/compute/test_global_forwarding_rules.rb create mode 100644 test/integration/factories/global_forwarding_rules_factory.rb diff --git a/lib/fog/google/models/compute/global_forwarding_rules.rb b/lib/fog/google/models/compute/global_forwarding_rules.rb index 955a60e313..ada8075f77 100644 --- a/lib/fog/google/models/compute/global_forwarding_rules.rb +++ b/lib/fog/google/models/compute/global_forwarding_rules.rb @@ -13,9 +13,11 @@ def all end def get(identity, region='global') - response = service.get_global_forwarding_rule(identity, region) - return nil if response.nil? - new(response.body) + if global_forwarding_rule = service.get_global_forwarding_rule(identity, region).body + new(global_forwarding_rule) + end + rescue Fog::Errors::NotFound + nil end end end diff --git a/test/integration/compute/test_global_forwarding_rules.rb b/test/integration/compute/test_global_forwarding_rules.rb new file mode 100644 index 0000000000..5e6ead231b --- /dev/null +++ b/test/integration/compute/test_global_forwarding_rules.rb @@ -0,0 +1,11 @@ +require "helpers/integration_test_helper" +require "integration/factories/global_forwarding_rules_factory" + +class TestGlobalForwardingRules < FogIntegrationTest + include TestCollection + + def setup + @subject = Fog::Compute[:google].global_forwarding_rules + @factory = GlobalForwardingRulesFactory.new(namespaced_name) + end +end diff --git a/test/integration/factories/global_forwarding_rules_factory.rb b/test/integration/factories/global_forwarding_rules_factory.rb new file mode 100644 index 0000000000..fe27d6ffea --- /dev/null +++ b/test/integration/factories/global_forwarding_rules_factory.rb @@ -0,0 +1,19 @@ +require "integration/factories/collection_factory" +require "integration/factories/target_http_proxies_factory" + +class GlobalForwardingRulesFactory < CollectionFactory + def initialize(example) + @targets = TargetHttpProxiesFactory.new(example) + super(Fog::Compute[:google].global_forwarding_rules, example) + end + + def cleanup + super + @targets.cleanup + end + + def params + params = {:name => resource_name, + :target => @targets.create.self_link} + end +end