Sha256: 6dcdcf0a9a35a90d3bd50978912fec7e4558c5868a055ebbaa40428170ad9dd6

Contents?: true

Size: 1.64 KB

Versions: 13

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

require File.join(File.dirname(__FILE__), 'test_helper')

describe 'ping' do
  let(:base_cmd) { %w[ping] }

  describe 'foreman' do
    let(:cmd) { base_cmd << 'foreman' }
    let(:ping_results) do
      {
        'results' => {
          'foreman' => {
            'database' => { 'active' => true, 'duration_ms' => 0 }
          }
        }
      }
    end

    it 'pings foreman system' do
      api_expects(:ping, :ping, 'Ping').returns(ping_results)

      output = OutputMatcher.new(
        [
          'database:',
          '    Status:          ok',
          '    Server Response: Duration: 0ms'
        ]
      )

      expected_result = success_result(output)
      result = run_cmd(cmd)
      assert_cmd(expected_result, result)
    end

    it 'returns 1 if one of the services failed and shows unrecognized services' do
      ping_results['results']['new_plugin'] = {
        'services' => {
          'first' => {
            'status' => 'FAIL'
          },
          'second' => {
            'status' => 'ok'
          }
        },
        'status' => 'FAIL'
      }
      api_expects(:ping, :ping, 'Ping').returns(ping_results)

      expected_result = CommandExpectation.new
      expected_result.expected_out = OutputMatcher.new(
        [
          'database:',
          '    Status:          ok',
          '    Server Response: Duration: 0ms'
        ]
      )
      expected_result.expected_err =
        ['1 more service(s) failed, but not shown:',
         'first',
         ''].join("\n")
      expected_result.expected_exit_code = 1
      result = run_cmd(cmd)
      assert_cmd(expected_result, result)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hammer_cli_foreman-3.8.0 test/functional/ping_test.rb
hammer_cli_foreman-3.7.0 test/functional/ping_test.rb
hammer_cli_foreman-3.5.1 test/functional/ping_test.rb
hammer_cli_foreman-3.6.0 test/functional/ping_test.rb
hammer_cli_foreman-3.5.0 test/functional/ping_test.rb
hammer_cli_foreman-3.4.0 test/functional/ping_test.rb
hammer_cli_foreman-3.3.0 test/functional/ping_test.rb
hammer_cli_foreman-3.2.0 test/functional/ping_test.rb
hammer_cli_foreman-2.5.2 test/functional/ping_test.rb
hammer_cli_foreman-3.1.0 test/functional/ping_test.rb
hammer_cli_foreman-3.0.0 test/functional/ping_test.rb
hammer_cli_foreman-2.5.1 test/functional/ping_test.rb
hammer_cli_foreman-2.5.0 test/functional/ping_test.rb