Sha256: 32c3f5e001c427e3f5f64b360e3217e899cc07932d01ccef40119e4a904dda3b

Contents?: true

Size: 1.71 KB

Versions: 31

Compression:

Stored size: 1.71 KB

Contents

describe HybridPlatformsConductor::ReportsHandler do

  # Setup a test platform for our reports testing
  #
  # Parameters::
  # * Proc: Code called when platform is setup
  def with_test_platform_for_reports_test
    with_test_platform({ nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {} } }) do
      register_report_plugins(test_reports_handler, report: HybridPlatformsConductorTest::ReportPlugin)
      test_reports_handler.format = :report
      yield
    end
  end

  it 'delivers a simple report on all the inventory' do
    with_test_platform_for_reports_test do
      test_reports_handler.produce_report_for [{ all: true }]
      expect(HybridPlatformsConductorTest::ReportPlugin.generated_reports).to eq ['Report generated for node1, node2, node3 in en']
    end
  end

  it 'delivers a simple report on some nodes only' do
    with_test_platform_for_reports_test do
      test_reports_handler.produce_report_for %w[node1 node3]
      expect(HybridPlatformsConductorTest::ReportPlugin.generated_reports).to eq ['Report generated for node1, node3 in en']
    end
  end

  it 'delivers a simple report with a different locale' do
    with_test_platform_for_reports_test do
      test_reports_handler.locale = :fr
      test_reports_handler.produce_report_for [{ all: true }]
      expect(HybridPlatformsConductorTest::ReportPlugin.generated_reports).to eq ['Report generated for node1, node2, node3 in fr']
    end
  end

  it 'fails when delivering a simple report with an unknown locale' do
    with_test_platform_for_reports_test do
      test_reports_handler.locale = :de
      expect { test_reports_handler.produce_report_for([{ all: true }]) }.to raise_error(RuntimeError, 'Unknown locale for format report: de')
    end
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.5 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.9.4 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.9.2 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.9.1 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.9.0 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.8.4 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.8.3 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.8.2 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.8.1 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.8.0 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.7.4 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.7.3 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.7.2 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.7.1 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.7.0 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.6.0 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.5.1 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.5.0 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.4.0 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb
hybrid_platforms_conductor-33.3.0 spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb