Sha256: e44b0776d6d664353d20f0b5ff7facaf2c1c52b696488d36974861580bb89817

Contents?: true

Size: 1.18 KB

Versions: 23

Compression:

Stored size: 1.18 KB

Contents

require "helpers/test_helper"

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

    # Do not test models that do not have a create method in API
    exceptions = [Fog::Compute::Google::MachineType,
                  Fog::Compute::Google::Region,
                  Fog::Compute::Google::DiskType,
                  Fog::Compute::Google::Operation,
                  Fog::Compute::Google::Zone,
                  Fog::Compute::Google::Snapshot,
                  Fog::Compute::Google::Project]
    # Enumerate all descendants of Fog::Model
    descendants = ObjectSpace.each_object(Fog::Model.singleton_class).to_a

    @models = descendants.select { |d| d.name.match(/Fog::Compute::Google/) } - exceptions
  end

  def teardown
    Fog.unmock!
  end

  def test_common_methods
    # This tests whether Fog::Compute::Google models have common lifecycle methods
    @models.each do |klass|
      obj = klass.new
      assert obj.respond_to?(:save), "#{klass} should have a .save method"
      assert obj.respond_to?(:destroy), "#{klass} should have a .destroy method"
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

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