Sha256: 5037b76c6ab3e72926eae6d4aaddc4829f459b62caf8d656b30bfa65a14f23b2

Contents?: true

Size: 1.39 KB

Versions: 23

Compression:

Stored size: 1.39 KB

Contents

require "helpers/test_helper"

class UnitTestMonitoringCollections < MiniTest::Test
  def setup
    Fog.mock!
    @client = Fog::Monitoring.new(provider: "google",
                                  google_project: "foo")

    # Exceptions that do not pass test_common_methods:
    #
    # TimeSeries API has no 'get' method
    @common_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 { |d| d.name.match(/Fog::Google::Monitoring/) }
  end

  def teardown
    Fog.unmock!
  end

  # This tests whether Fog::Compute::Google collections have common lifecycle methods
  def test_common_methods
    subjects = @collections - @common_method_exceptions

    subjects.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
      if obj.respond_to?(:get)
        assert_operator(obj.method(:get).arity, :<=, 1,
                        "#{klass} should have at most 1 required parameter in get()")
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
fog-google-1.22.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.21.1 test/unit/monitoring/test_comon_collections.rb
fog-google-1.21.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.20.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.19.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.18.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.17.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.16.1 test/unit/monitoring/test_comon_collections.rb
fog-google-1.16.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.15.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.14.0 test/unit/monitoring/test_comon_collections.rb
gitlab-fog-google-1.14.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.13.0 test/unit/monitoring/test_comon_collections.rb
gitlab-fog-google-1.13.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.12.1 test/unit/monitoring/test_comon_collections.rb
fog-google-1.12.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.11.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.10.0 test/unit/monitoring/test_comon_collections.rb
fog-google-1.9.1 test/unit/monitoring/test_comon_collections.rb
fog-google-1.9.0 test/unit/monitoring/test_comon_collections.rb