forked from fog/fog-google
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ test fixtures for fog#352
- Loading branch information
Showing
8 changed files
with
253 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "helpers/test_helper" | ||
require "pry" | ||
|
||
class UnitTestDNSCollections < MiniTest::Test | ||
def setup | ||
Fog.mock! | ||
@client = Fog::DNS.new(provider: "google") | ||
|
||
# DNS Projects API does not support 'list', so 'all' method is not possible | ||
exceptions = [Fog::DNS::Google::Projects] | ||
# Enumerate all descendants of Fog::Collection | ||
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class) | ||
|
||
@collections = descendants.select { |x| x.name.match /Fog::DNS::Google/ } - exceptions | ||
end | ||
|
||
def teardown | ||
Fog.unmock! | ||
end | ||
|
||
def test_common_methods | ||
# This tests whether Fog::Compute::Google collections have common lifecycle methods | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert obj.respond_to?(:all), "#{klass} should have an .all method" | ||
assert obj.respond_to?(:get), "#{klass} should have a .get method" | ||
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable" | ||
end | ||
end | ||
|
||
def test_collection_get_arguments | ||
# TODO: Fixture for #352 | ||
skip | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert_operator(obj.method(:get).arity, :<=, 1, | ||
"#{klass} should have at most 1 required parameter in get()") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "helpers/test_helper" | ||
require "pry" | ||
|
||
class UnitTestMonitoringCollections < MiniTest::Test | ||
def setup | ||
Fog.mock! | ||
@client = Fog::Monitoring.new(provider: "google") | ||
|
||
# TimeSeries API has no 'get' method | ||
exceptions = [Fog::Google::Monitoring::TimeseriesCollection] | ||
# Enumerate all descendants of Fog::Collection | ||
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class).to_a | ||
|
||
@collections = descendants.select { |x| x.name.match /Fog::Google::Monitoring/ } - exceptions | ||
end | ||
|
||
def teardown | ||
Fog.unmock! | ||
end | ||
|
||
def test_common_methods | ||
# This tests whether Fog::Compute::Google collections have common lifecycle methods | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert obj.respond_to?(:all), "#{klass} should have an .all method" | ||
assert obj.respond_to?(:get), "#{klass} should have a .get method" | ||
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable" | ||
end | ||
end | ||
|
||
def test_collection_get_arguments | ||
# TODO: Fixture for #352 | ||
skip | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert_operator(obj.method(:get).arity, :<=, 1, | ||
"#{klass} should have at most 1 required parameter in get()") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require "helpers/test_helper" | ||
require "pry" | ||
|
||
class UnitTestPubsubCollections < MiniTest::Test | ||
def setup | ||
Fog.mock! | ||
@client = Fog::Google::Pubsub.new | ||
|
||
exceptions = [] | ||
# Enumerate all descendants of Fog::Collection | ||
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class) | ||
|
||
@collections = descendants.select { |x| x.name.match /Fog::Google::Pubsub/ } - exceptions | ||
end | ||
|
||
def teardown | ||
Fog.unmock! | ||
end | ||
|
||
def test_common_methods | ||
# This tests whether Fog::Compute::Google collections have common lifecycle methods | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert obj.respond_to?(:all), "#{klass} should have an .all method" | ||
assert obj.respond_to?(:get), "#{klass} should have a .get method" | ||
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable" | ||
end | ||
end | ||
|
||
def test_collection_get_arguments | ||
# TODO: Fixture for #352 | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert_operator(obj.method(:get).arity, :<=, 1, | ||
"#{klass} should have at most 1 required parameter in get()") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "helpers/test_helper" | ||
require "pry" | ||
|
||
class UnitTestSQLCollections < MiniTest::Test | ||
def setup | ||
Fog.mock! | ||
@client = Fog::Google::SQL.new | ||
|
||
# SQL Users API doesn't have a get method | ||
# SQL Flags API has only a 'list' method | ||
exceptions = [Fog::Google::SQL::Users, | ||
Fog::Google::SQL::Tiers, | ||
Fog::Google::SQL::Flags] | ||
# Enumerate all descendants of Fog::Collection | ||
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class) | ||
|
||
@collections = descendants.select { |x| x.name.match /Fog::Google::SQL/ } - exceptions | ||
end | ||
|
||
def teardown | ||
Fog.unmock! | ||
end | ||
|
||
def test_common_methods | ||
# This tests whether Fog::Compute::Google collections have common lifecycle methods | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert obj.respond_to?(:all), "#{klass} should have an .all method" | ||
assert obj.respond_to?(:get), "#{klass} should have a .get method" | ||
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable" | ||
end | ||
end | ||
|
||
def test_collection_get_arguments | ||
# TODO: Fixture for #352 | ||
skip | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert_operator(obj.method(:get).arity, :<=, 1, | ||
"#{klass} should have at most 1 required parameter in get()") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require "helpers/test_helper" | ||
require "pry" | ||
|
||
class UnitTestStorageJSONCollections < MiniTest::Test | ||
def setup | ||
Fog.mock! | ||
@client = Fog::Storage.new(provider: "google") | ||
|
||
# Enumerate all descendants of Fog::Collection | ||
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class) | ||
|
||
@collections = descendants.select { | ||
|x| x.name.match /Fog::Storage::GoogleJSON/ | ||
} | ||
end | ||
|
||
def teardown | ||
Fog.unmock! | ||
end | ||
|
||
def test_common_methods | ||
# This tests whether Fog::Compute::Google collections have common lifecycle methods | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert obj.respond_to?(:all), "#{klass} should have an .all method" | ||
assert obj.respond_to?(:get), "#{klass} should have a .get method" | ||
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable" | ||
end | ||
end | ||
|
||
def test_collection_get_arguments | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert_operator(obj.method(:get).arity, :<=, 1, | ||
"#{klass} should have at most 1 required parameter in get()") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "helpers/test_helper" | ||
require "pry" | ||
|
||
class UnitTestStorageXMLCollections < MiniTest::Test | ||
def setup | ||
Fog.mock! | ||
@client = Fog::Storage.new(provider: "google", | ||
google_storage_access_key_id: "", | ||
google_storage_secret_access_key: "") | ||
|
||
# Enumerate all descendants of Fog::Collection | ||
descendants = ObjectSpace.each_object(Fog::Collection.singleton_class) | ||
|
||
@collections = descendants.select { | ||
|x| x.name.match /Fog::Storage::GoogleXML/ | ||
} | ||
end | ||
|
||
def teardown | ||
Fog.unmock! | ||
end | ||
|
||
def test_common_methods | ||
# This tests whether Fog::Compute::Google collections have common lifecycle methods | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert obj.respond_to?(:all), "#{klass} should have an .all method" | ||
assert obj.respond_to?(:get), "#{klass} should have a .get method" | ||
assert obj.respond_to?(:each), "#{klass} should behave like Enumerable" | ||
end | ||
end | ||
|
||
def test_collection_get_arguments | ||
@collections.each do |klass| | ||
obj = klass.new | ||
assert_operator(obj.method(:get).arity, :<=, 1, | ||
"#{klass} should have at most 1 required parameter in get()") | ||
end | ||
end | ||
end |