Sha256: 766c82c317225f92bd05ffaafe9ac3e226528f0fd1f9407fb479df28baa19101
Contents?: true
Size: 1.48 KB
Versions: 104
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require 'test_plugin_helper' # Unit tests for AnsibleReportImporter # This class is just meant to capture the config reports coming # from Ansible and change anything that is required class AnsibleReportImporterTest < ActiveSupport::TestCase setup do @raw = { 'host' => '192.168.121.1' } @importer = ::ConfigReportImporter.new(@raw) end test 'finds host when the hostname is given as the IP' do host = ::FactoryBot.create(:host, :ip => @raw['host']) ForemanAnsible::AnsibleReportScanner.expects(:ansible_report?).returns(true) assert_equal @importer.host, host end test 'creates new host if IP is not found' do ForemanAnsible::AnsibleReportScanner.expects(:ansible_report?).returns(true) assert @importer.host.new_record? end test 'finds host when given partially qualified name' do host = ::FactoryBot.create(:host, :hostname => 'ansible-host.example.com') ForemanAnsible::AnsibleReportScanner.expects(:ansible_report?).returns(true) assert_equal host, ::ConfigReportImporter.new({ 'host' => 'ansible-host' }).host end test 'creates a new host when multiple hosts for partially qualified name are found' do ::FactoryBot.create(:host, :hostname => 'ansible-host.example.com') ::FactoryBot.create(:host, :hostname => 'ansible-host.dummy.org') ForemanAnsible::AnsibleReportScanner.expects(:ansible_report?).returns(true) assert ::ConfigReportImporter.new({ 'host' => 'ansible-host' }).host.new_record? end end
Version data entries
104 entries across 104 versions & 1 rubygems