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-1.0.4 test/unit/metadata_generator_test.rb
foreman_rh_cloud-2.0.4 test/unit/metadata_generator_test.rb
foreman_rh_cloud-0.9.4 test/unit/metadata_generator_test.rb
foreman_inventory_upload-2.0.4.pre.2 test/unit/metadata_generator_test.rb
foreman_inventory_upload-2.0.4.pre.1 test/unit/metadata_generator_test.rb
foreman_inventory_upload-2.0.3 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.3 test/unit/metadata_generator_test.rb
foreman_inventory_upload-0.9.2 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.2 test/unit/metadata_generator_test.rb
foreman_inventory_upload-0.9.1 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.1 test/unit/metadata_generator_test.rb
foreman_inventory_upload-0.9.0 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0.beta7 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0.beta6 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0.beta5 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0.beta4 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0.beta3 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0.beta2 test/unit/metadata_generator_test.rb
foreman_inventory_upload-1.0.0.beta1 test/unit/metadata_generator_test.rb