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-6.0.45 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.46 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.45 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.44 test/unit/metadata_generator_test.rb
foreman_rh_cloud-7.0.45 test/unit/metadata_generator_test.rb
foreman_rh_cloud-6.0.44 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.43 test/unit/metadata_generator_test.rb
foreman_rh_cloud-4.0.36 test/unit/metadata_generator_test.rb
foreman_rh_cloud-3.0.33 test/unit/metadata_generator_test.rb
foreman_rh_cloud-6.0.42.2 test/unit/metadata_generator_test.rb
foreman_rh_cloud-6.0.42.1 test/unit/metadata_generator_test.rb
foreman_rh_cloud-6.0.43 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.42 test/unit/metadata_generator_test.rb
foreman_rh_cloud-6.0.42 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.41 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.39 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.38 test/unit/metadata_generator_test.rb
foreman_rh_cloud-4.0.35 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.37 test/unit/metadata_generator_test.rb
foreman_rh_cloud-5.0.36 test/unit/metadata_generator_test.rb