Sha256: 04a0d1a66d12a5209bc719bc1ee12f6ca023896074334b77b1b090536917d74f

Contents?: true

Size: 959 Bytes

Versions: 3

Compression:

Stored size: 959 Bytes

Contents

require 'test_puppet_helper'

module ForemanPuppet
  class SmartProxyTest < ActiveSupport::TestCase
    let(:proxy) { FactoryBot.create(:puppet_smart_proxy) }

    test 'should return environment stats' do
      ProxyAPI::Puppet.any_instance.expects(:environments).returns(%w[env1 env2])
      ProxyAPI::Puppet.any_instance.expects(:class_count).with('env1').returns(1)
      ProxyAPI::Puppet.any_instance.expects(:class_count).with('env2').returns(2)
      assert_equal({ 'env1' => 1, 'env2' => 2 }, proxy.statuses[:puppet].environment_stats)
    end

    describe 'older v1 api' do
      before do
        ProxyAPI::V2::Features.any_instance.stubs(:features).raises(NotImplementedError.new('not supported'))
      end

      test 'can count connected hosts' do
        FactoryBot.create(:host, :with_puppet_enc, :with_environment, puppet_proxy: proxy)

        as_admin do
          assert_equal 1, proxy.hosts_count
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_puppet-0.1.0 test/models/foreman_puppet/smart_proxy_test.rb
foreman_puppet-0.0.2 test/models/foreman_puppet/smart_proxy_test.rb
foreman_puppet-0.0.1 test/models/foreman_puppet/smart_proxy_test.rb