Sha256: 322a21e67bea4a034b2d1afb0a3e8a03dbacaaaf31a7962afc65281c646f1fa7

Contents?: true

Size: 988 Bytes

Versions: 8

Compression:

Stored size: 988 Bytes

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
      ForemanSalt::ReportImporter.import(@report)
      assert_equal Host.find_by_name(@host).host_status, '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

8 entries across 8 versions & 1 rubygems

Version Path
foreman_salt-3.0.2 test/unit/report_importer_test.rb
foreman_salt-3.0.1 test/unit/report_importer_test.rb
foreman_salt-3.0.0 test/unit/report_importer_test.rb
foreman_salt-2.1.0 test/unit/report_importer_test.rb
foreman_salt-2.0.2 test/unit/report_importer_test.rb
foreman_salt-2.0.1 test/unit/report_importer_test.rb
foreman_salt-2.0.0 test/unit/report_importer_test.rb
foreman_salt-1.1.1 test/unit/report_importer_test.rb