Skip to content

Commit

Permalink
Refs #36641 - also don't override metadata (#10684)
Browse files Browse the repository at this point in the history
metadata is a reserved thing in minitest
  • Loading branch information
evgeni authored Aug 7, 2023
1 parent 59c9eb7 commit 9561993
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ImportLibraryTest < ActiveSupport::TestCase
end
end

let(:metadata) do
let(:import_metadata) do
{
products: {
prod.label => prod.slice(:name, :label).merge(redhat: prod.redhat?)
Expand Down Expand Up @@ -98,11 +98,11 @@ def setup_proxy
assert_nil ::Katello::ContentView.where(organization: organization,
name: ::Katello::ContentView::IMPORT_LIBRARY).first
action_class.any_instance.expects(:action_subject).with(organization)
plan_action(action, organization, path: path, metadata: metadata)
plan_action(action, organization, path: path, metadata: import_metadata)
assert_action_planned_with(action, ::Actions::Katello::ContentViewVersion::Import) do |options|
options = options.first if options.is_a? Array
assert_equal options[:organization], organization
assert_equal options[:metadata], metadata
assert_equal options[:metadata], import_metadata
assert_equal options[:path], path
end
end
Expand All @@ -111,7 +111,7 @@ def setup_proxy
::Katello::ContentViewManager.expects(:create_candlepin_environment).returns
::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns

tree = plan_action_tree(action_class, organization, path: path, metadata: metadata)
tree = plan_action_tree(action_class, organization, path: path, metadata: import_metadata)

assert_empty tree.errors
assert_tree_planned_with(tree, Actions::Pulp3::Repository::CopyContent) do |input|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ImportLibraryTest < ActiveSupport::TestCase
end
end

let(:metadata) do
let(:import_metadata) do
prod = katello_products(:redhat)

{
Expand Down Expand Up @@ -83,11 +83,11 @@ def setup_proxy
describe 'Import Repository' do
it 'should plan properly' do
action_class.any_instance.expects(:action_subject).with(organization)
plan_action(action, organization, path: path, metadata: metadata)
plan_action(action, organization, path: path, metadata: import_metadata)
assert_action_planned_with(action, ::Actions::Katello::ContentViewVersion::Import) do |options|
options = options.first if options.is_a? Array
assert_equal options[:organization], organization
assert_equal options[:metadata], metadata
assert_equal options[:metadata], import_metadata
assert_equal options[:path], path
end
end
Expand All @@ -96,7 +96,7 @@ def setup_proxy
::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns
::Katello::ContentViewManager.expects(:create_candlepin_environment).returns

tree = plan_action_tree(action_class, organization, path: path, metadata: metadata)
tree = plan_action_tree(action_class, organization, path: path, metadata: import_metadata)
assert_empty tree.errors
assert_tree_planned_with(tree, Actions::Pulp3::Repository::CopyContent) do |input|
assert input[:copy_all]
Expand Down
50 changes: 25 additions & 25 deletions test/actions/katello/content_view_version/import_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TestBase < ActiveSupport::TestCase
katello_products(:redhat)
end

let(:metadata) do
let(:import_metadata) do
{
products: {
prod.label => prod.slice(:label, :name).merge(redhat: prod.redhat?)
Expand Down Expand Up @@ -95,56 +95,56 @@ class ImportTest < TestBase
describe 'Import' do
it 'should fail on importing content for an existing versions' do
exception = assert_raises(RuntimeError) do
plan_action(action, organization: organization, path: path, metadata: metadata)
plan_action(action, organization: organization, path: path, metadata: import_metadata)
end
assert_match(/'#{content_view_version.name}' already exists/, exception.message)
end

it 'should plan properly' do
metadata[:content_view_version][:major] += 10
import_metadata[:content_view_version][:major] += 10

::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns

plan_action(action, organization: organization, path: path, metadata: metadata)
plan_action(action, organization: organization, path: path, metadata: import_metadata)
assert_action_planned_with(action,
::Actions::Katello::ContentView::Publish,
content_view, description,
path: path,
metadata: metadata,
metadata: import_metadata,
importing: true,
syncable: false,
major: metadata[:content_view_version][:major],
minor: metadata[:content_view_version][:minor])
major: import_metadata[:content_view_version][:major],
minor: import_metadata[:content_view_version][:minor])
end

it 'should create a non existent cv and plan properly' do
metadata[:content_view] = { name: "non_existent_view", label: "nope", generated_for: :none }
import_metadata[:content_view] = { name: "non_existent_view", label: "nope", generated_for: :none }
::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns

plan_action(action, organization: organization, path: path, metadata: metadata)
content_view = ::Katello::ContentView.find_by(label: metadata[:content_view][:label],
plan_action(action, organization: organization, path: path, metadata: import_metadata)
content_view = ::Katello::ContentView.find_by(label: import_metadata[:content_view][:label],
organization: organization)
refute_nil content_view
assert content_view.import_only?
assert_action_planned_with(action,
::Actions::Katello::ContentView::Publish,
content_view, description,
path: path,
metadata: metadata,
metadata: import_metadata,
importing: true,
syncable: false,
major: metadata[:content_view_version][:major],
minor: metadata[:content_view_version][:minor])
major: import_metadata[:content_view_version][:major],
minor: import_metadata[:content_view_version][:minor])
end

it 'should create the library cv and plan properly' do
metadata[:content_view] = { name: ::Katello::ContentView::EXPORT_LIBRARY,
label: ::Katello::ContentView::EXPORT_LIBRARY,
generated_for: :library_export
}
import_metadata[:content_view] = { name: ::Katello::ContentView::EXPORT_LIBRARY,
label: ::Katello::ContentView::EXPORT_LIBRARY,
generated_for: :library_export
}
::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns

plan_action(action, organization: organization, path: path, metadata: metadata)
plan_action(action, organization: organization, path: path, metadata: import_metadata)
content_view = ::Katello::ContentView.find_by(label: ::Katello::ContentView::IMPORT_LIBRARY,
organization: organization)
refute_nil content_view
Expand All @@ -153,20 +153,20 @@ class ImportTest < TestBase
::Actions::Katello::ContentView::Publish,
content_view, description,
path: path,
metadata: metadata,
metadata: import_metadata,
importing: true,
syncable: false,
major: metadata[:content_view_version][:major],
minor: metadata[:content_view_version][:minor])
major: import_metadata[:content_view_version][:major],
minor: import_metadata[:content_view_version][:minor])
end

it 'should plan the full tree appropriately' do
::Katello::Pulp3::ContentViewVersion::Import.any_instance.expects(:check!).returns

::Katello::ContentViewManager.expects(:create_candlepin_environment).returns
metadata[:content_view_version][:major] += 10
import_metadata[:content_view_version][:major] += 10
generated_cvv = nil
tree = plan_action_tree(action_class, organization: organization, path: path, metadata: metadata)
tree = plan_action_tree(action_class, organization: organization, path: path, metadata: import_metadata)

assert_empty tree.errors
assert_tree_planned_steps(tree, Actions::Katello::ContentView::AddToEnvironment)
Expand All @@ -179,8 +179,8 @@ class ImportTest < TestBase
assert_equal path, input[:path]
generated_cvv = ::Katello::ContentViewVersion.find(input[:content_view_version_id])
assert_equal content_view_version.content_view.id, generated_cvv.content_view.id
assert_equal metadata[:content_view_version][:major], generated_cvv.major
assert_equal metadata[:content_view_version][:minor], generated_cvv.minor
assert_equal import_metadata[:content_view_version][:major], generated_cvv.major
assert_equal import_metadata[:content_view_version][:minor], generated_cvv.minor
end

assert_tree_planned_with(tree, Actions::Pulp3::ContentViewVersion::CreateImport) do |input|
Expand Down

0 comments on commit 9561993

Please sign in to comment.