Sha256: b34971d12d85132a29d1a0219e3b3be0b8ce9f2d34696acb494981829ccda8e4

Contents?: true

Size: 1.88 KB

Versions: 46

Compression:

Stored size: 1.88 KB

Contents

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

# Test class for Network Security Group Collection
class TestNetworkSecurityGroups < Minitest::Test
  def setup
    @service = Fog::Network::AzureRM.new(credentials)
    client = @service.instance_variable_get(:@network_client)
    @network_security_groups = Fog::Network::AzureRM::NetworkSecurityGroups.new(resource_group: 'fog-test-rg', service: @service)
    @response = [ApiStub::Models::Network::NetworkSecurityGroup.create_network_security_group_response(client)]
  end

  def test_collection_methods
    methods = [
      :all,
      :get,
      :check_net_sec_group_exists
    ]
    methods.each do |method|
      assert_respond_to @network_security_groups, method
    end
  end

  def test_collection_attributes
    assert_respond_to @network_security_groups, :resource_group
  end

  def test_all_method_response
    @service.stub :list_network_security_groups, @response do
      assert_instance_of Fog::Network::AzureRM::NetworkSecurityGroups, @network_security_groups.all
      assert @network_security_groups.all.size >= 1
      @network_security_groups.all.each do |nsg|
        assert_instance_of Fog::Network::AzureRM::NetworkSecurityGroup, nsg
      end
    end
  end

  def test_get_method_response
    @service.stub :get_network_security_group, @response[0] do
      assert_instance_of Fog::Network::AzureRM::NetworkSecurityGroup, @network_security_groups.get('fog-test-rg', 'fog-test-nsg')
    end
  end

  def test_check_net_sec_group_exists_true_response
    @service.stub :check_net_sec_group_exists, true do
      assert @network_security_groups.check_net_sec_group_exists('fog-test-rg', 'fog-test-nsg')
    end
  end

  def test_check_net_sec_group_exists_false_response
    @service.stub :check_net_sec_group_exists, false do
      assert !@network_security_groups.check_net_sec_group_exists('fog-test-rg', 'fog-test-nsg')
    end
  end
end

Version data entries

46 entries across 46 versions & 4 rubygems

Version Path
fog-azure-rm-0.2.5 test/models/network/test_network_security_groups.rb
fog-azure-rm-0.2.4 test/models/network/test_network_security_groups.rb
fog-azure-rm-0.2.3 test/models/network/test_network_security_groups.rb
fog-azure-rm-0.2.2 test/models/network/test_network_security_groups.rb
fog-azure-rm-0.2.1 test/models/network/test_network_security_groups.rb
fog-azure-rm-0.2.0 test/models/network/test_network_security_groups.rb