Sha256: 25d67bcdcd693dd506884100422336692981e087606f92fb6a531fd3be038970

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

require File.expand_path '../../test_helper', __dir__

# Test class for Servers Collection
class TestServers < Minitest::Test
  def setup
    @service = Fog::Compute::AzureRM.new(credentials)
    @servers = Fog::Compute::AzureRM::Servers.new(resource_group: 'fog-test-rg', service: @service)
    @compute_client = @service.instance_variable_get(:@compute_mgmt_client)
    @response = [ApiStub::Models::Compute::Server.create_windows_virtual_machine_response(@compute_client)]
  end

  def test_collection_methods
    methods = [
      :all,
      :get,
      :get_from_remote
    ]
    methods.each do |method|
      assert @servers.respond_to? method, true
    end
  end

  def test_collection_attributes
    assert @servers.respond_to? :resource_group, true
  end

  def test_all_method_response
    @service.stub :list_virtual_machines, @response do
      assert_instance_of Fog::Compute::AzureRM::Servers, @servers.all
      assert @servers.all.size >= 1
      @servers.all.each do |s|
        assert_instance_of Fog::Compute::AzureRM::Server, s
      end
    end
  end

  def test_get_method_response
    @service.stub :list_virtual_machines, @response do
      assert_instance_of Fog::Compute::AzureRM::Server, @servers.get('fog-test-server')
      assert @servers.get('wrong-name').nil?, true
    end
  end

  def test_get_from_remote_method_response
    response = ApiStub::Models::Compute::Server.create_windows_virtual_machine_response(@compute_client)
    @service.stub :get_virtual_machine, response do
      assert_instance_of Fog::Compute::AzureRM::Server, @servers.get_from_remote('fog-test-rg', 'fog-test-server')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.5 test/models/compute/test_servers.rb