Sha256: 86efe211a778720a57fd48850b6da4384c6efbcc71d77f9dc65f0b17ef1df350

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

require 'test_plugin_helper'

module ForemanSalt
  class ReportImporterTest < ActiveSupport::TestCase
    setup do
      User.current = User.find_by_login 'admin'
      Setting[:create_new_host_when_facts_are_uploaded] = true

      @report = JSON.parse(File.read(File.join(Engine.root, 'test', 'unit', 'highstate.json')))

      @host = 'saltclient713.example.com'
    end

    test 'importing report creates a host' do
      refute Host.find_by_name(@host)
      ForemanSalt::ReportImporter.import(@report)
      assert Host.find_by_name(@host)
    end

    test 'importing report updates host status' do
      HostStatus::ConfigurationStatus.any_instance.stubs(:relevant?).returns(true)
      ForemanSalt::ReportImporter.import(@report)
      assert Host.find_by_name(@host).get_status(HostStatus::ConfigurationStatus).error?
    end

    test 'importing report has correct status' do
      ForemanSalt::ReportImporter.import(@report)
      status = Host.find_by_name(@host).reports.last.status
      assert_equal status['applied'], 9
      assert_equal status['failed'], 3
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
foreman_salt-10.1.0 test/unit/report_importer_test.rb
foreman_salt-8.0.4 test/unit/report_importer_test.rb
foreman_salt-9.0.1 test/unit/report_importer_test.rb
foreman_salt-10.0.0 test/unit/report_importer_test.rb
foreman_salt-9.0.0 test/unit/report_importer_test.rb
foreman_salt-8.0.3 test/unit/report_importer_test.rb
foreman_salt-8.0.2 test/unit/report_importer_test.rb
foreman_salt-8.0.1 test/unit/report_importer_test.rb
foreman_salt-7.0.3 test/unit/report_importer_test.rb
foreman_salt-8.0.0 test/unit/report_importer_test.rb
foreman_salt-7.0.2 test/unit/report_importer_test.rb
foreman_salt-6.0.1 test/unit/report_importer_test.rb
foreman_salt-7.0.1 test/unit/report_importer_test.rb
foreman_salt-7.0.0 test/unit/report_importer_test.rb
foreman_salt-6.0.0 test/unit/report_importer_test.rb
foreman_salt-5.0.1 test/unit/report_importer_test.rb
foreman_salt-5.0.0 test/unit/report_importer_test.rb