Sha256: efde449f945ee686b4f5af4c21f30edcab9db8618b5d035d874b5d4a73b63b23

Contents?: true

Size: 1.17 KB

Versions: 41

Compression:

Stored size: 1.17 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_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

41 entries across 41 versions & 2 rubygems

Version Path
foreman_rh_cloud-0.9.10 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.10 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.10 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.9 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.9 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.9 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.8 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.8 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.8 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.7 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.7 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.7 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.6 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.6 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.6 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.5 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.5 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.5 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.4.1 test/unit/metadata_generator_test.rb
foreman_rh_cloud-1.0.4.1 test/unit/metadata_generator_test.rb