Sha256: d06d09cb2d4e6e1c6ca7c1da5cf8a79274136618d7d4da30bf73a8939effaabb

Contents?: true

Size: 1.31 KB

Versions: 84

Compression:

Stored size: 1.31 KB

Contents

require 'test_plugin_helper'

class MetadataGeneratorTest < ActiveSupport::TestCase
  setup do
  end

  test 'generates an empty report' do
    generator = ForemanInventoryUpload::Generators::Metadata.new

    json_str = generator.render do
    end
    actual = JSON.parse(json_str.join("\n"))

    assert_not_nil actual['report_id']
    assert_equal 'Satellite', actual['source']
    assert_not_nil (actual_metadata = actual['source_metadata'])
    assert_equal ForemanRhCloud::VERSION, actual_metadata['foreman_rh_cloud_version']
    assert_equal({}, actual['report_slices'])
  end

  test 'generates a report for a single slice' do
    generator = ForemanInventoryUpload::Generators::Metadata.new

    json_str = generator.render do |gen|
      gen.add_slice('test_123', 1, true)
      gen.add_slice('test_1234', 2, false)
      gen.add_slice('test_12345', 3, false)
    end

    actual = JSON.parse(json_str.join("\n"))

    assert_not_nil actual['report_id']
    assert_equal 'Satellite', actual['source']
    assert_not_nil(slices = actual['report_slices'])
    assert_not_nil(slice = slices['test_123'])
    assert_equal 1, slice['number_hosts']
    assert_not_nil(slice = slices['test_1234'])
    assert_equal 2, slice['number_hosts']
    assert_not_nil(slice = slices['test_12345'])
    assert_equal 3, slice['number_hosts']
  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.17 test/unit/metadata_generator_test.rb
foreman_rh_cloud-3.0.17 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.16 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.16 test/unit/metadata_generator_test.rb
foreman_rh_cloud-3.0.16 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.15 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.15 test/unit/metadata_generator_test.rb
foreman_rh_cloud-3.0.15 test/unit/metadata_generator_test.rb
foreman_rh_cloud-3.0.14 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.14 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.14 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.14 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.13.1 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.13.1 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.13.1 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.13 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.13 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.13 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.12 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.12 test/unit/metadata_generator_test.rb