Sha256: 3a2499f0b4393fb11968df72828cadd4f87cb9afcd557762653d0c13f9247ceb

Contents?: true

Size: 1.1 KB

Versions: 11

Compression:

Stored size: 1.1 KB

Contents

require 'test_plugin_helper'

class ForemanOpenscap::Oval::SetupCheckTest < ActiveSupport::TestCase
  test 'should show error message with filled in data' do
    check = ::ForemanOpenscap::Oval::SetupCheck.new(
      :id => :test_check,
      :title => _("Will it pass?"),
      :fail_msg => ->(hash) { "There was an error in #{hash[:name]}, you need to #{hash[:action]}" }
    )

    check.fail_with!(:name => 'your engine', :action => 'run')
    assert_equal 'There was an error in your engine, you need to run', check.fail_msg
  end

  test 'should show error message when it is a string' do
    msg = "Do not panic"
    check = ::ForemanOpenscap::Oval::SetupCheck.new(
      :id => :test_check,
      :title => _("Will it pass?"),
      :fail_msg => msg
    )
    check.fail!
    assert_equal msg, check.fail_msg
  end

  test 'should not show error message when check not failed' do
    check = ::ForemanOpenscap::Oval::SetupCheck.new(
      :id => :test_check,
      :title => _("Will it pass?"),
      :fail_msg => 'foo'
    )

    assert_nil check.fail_msg
    check.fail!
    assert_not_nil check.fail_msg
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
foreman_openscap-8.0.0 test/unit/services/oval/setup_check_test.rb
foreman_openscap-7.1.1 test/unit/services/oval/setup_check_test.rb
foreman_openscap-7.1.0 test/unit/services/oval/setup_check_test.rb
foreman_openscap-7.0.0 test/unit/services/oval/setup_check_test.rb
foreman_openscap-6.0.0 test/unit/services/oval/setup_check_test.rb
foreman_openscap-5.2.3 test/unit/services/oval/setup_check_test.rb
foreman_openscap-5.2.2 test/unit/services/oval/setup_check_test.rb
foreman_openscap-5.1.1 test/unit/services/oval/setup_check_test.rb
foreman_openscap-5.2.1 test/unit/services/oval/setup_check_test.rb
foreman_openscap-5.2.0 test/unit/services/oval/setup_check_test.rb
foreman_openscap-5.1.0 test/unit/services/oval/setup_check_test.rb