Sha256: 0801c966dccc1d8284f3800c10d66a38f5da471f020c7be79562c1a3fa39d3d3

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 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
    ]
    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
    response = [@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 :get_virtual_machine, @response do
      assert_instance_of Fog::Compute::AzureRM::Server, @servers.get('fog-test-rg', 'fog-test-server')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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