Sha256: 11ff5c82992d0f06d1a9240f63591e92220037ff9c0c489bd37bd718f9a5b8bf

Contents?: true

Size: 1.61 KB

Versions: 72

Compression:

Stored size: 1.61 KB

Contents

Shindo.tests('Fog::Compute[:vsphere]', ['vsphere']) do

  compute = Fog::Compute[:vsphere]

  tests("| convert_vm_mob_ref_to_attr_hash") do
    # Mock the RbVmomi::VIM::ManagedObject class
    class MockManagedObject
      attr_reader :parent, :_ref

      def initialize
        @parent = @_ref = 'vm-123'
      end

      def collect! *pathSet
        { '_ref' => 'vm-123', 'name' => 'fakevm' }
      end
    end

    fake_vm_mob_ref = MockManagedObject.new

    tests("When converting an incomplete vm object") do
      test("it should return a Hash") do
        compute.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref).kind_of? Hash
      end
      tests("The converted Hash should") do
        attr_hash = compute.send(:convert_vm_mob_ref_to_attr_hash, fake_vm_mob_ref)
        test("have a name") { attr_hash['name'] == 'fakevm' }
        test("have a mo_ref") {attr_hash['mo_ref'] == 'vm-123' }
        test("have an id") { attr_hash['id'] == 'vm-123' }
        test("not have a instance_uuid") { attr_hash['instance_uuid'].nil? }
      end
    end

    tests("When passed a nil object") do
      attr_hash = compute.send :convert_vm_mob_ref_to_attr_hash, nil
      test("it should return a nil object") do
        attr_hash.nil?
      end
    end
  end

  tests("Compute attributes") do
    %w{ vsphere_is_vcenter vsphere_rev vsphere_username vsphere_server }.each do |attr|
      test("it should respond to #{attr}") { compute.respond_to? attr }
    end
  end

  tests("Compute collections") do
    %w{ servers }.each do |collection|
      test("it should respond to #{collection}") { compute.respond_to? collection }
    end
  end
end

Version data entries

72 entries across 72 versions & 5 rubygems

Version Path
fog-vsphere-2.1.1 tests/compute_tests.rb
fog-vsphere-2.1.0 tests/compute_tests.rb
fog-vsphere-2.0.1 tests/compute_tests.rb
fog-vsphere-2.0.0 tests/compute_tests.rb
fog-vsphere-1.13.1 tests/compute_tests.rb
fog-vsphere-1.13.0 tests/compute_tests.rb
fog-vsphere-1.12.0 tests/compute_tests.rb
fog-vsphere-1.11.3 tests/compute_tests.rb
fog-vsphere-1.11.2 tests/compute_tests.rb
fog-vsphere-1.11.1 tests/compute_tests.rb
fog-vsphere-1.11.0 tests/compute_tests.rb
fog-vsphere-1.10.0 tests/compute_tests.rb
fog-vsphere-1.9.2 tests/compute_tests.rb
fog-vsphere-1.9.1 tests/compute_tests.rb
fog-vsphere-1.9.0 tests/compute_tests.rb
fog-vsphere-1.8.0 tests/compute_tests.rb
fog-vsphere-1.7.1 tests/compute_tests.rb
fog-vsphere-1.7.0 tests/compute_tests.rb
fog-vsphere-1.6.0 tests/compute_tests.rb
fog-vsphere-1.5.2 tests/compute_tests.rb