Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1653) Ensure template have access to metadata during update/convert #883

Merged
merged 1 commit into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/pdk/module/convert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def stage_changes!(context = PDK.context)

# new_metadata == nil when creating a new module but with --noop@
module_name = new_metadata.nil? ? 'new-module' : new_metadata.data['name']
template_dir.render_new_module(module_name) do |relative_file_path, file_content, file_status|
metadata_for_render = new_metadata.nil? ? {} : new_metadata.data

template_dir.render_new_module(module_name, metadata_for_render) do |relative_file_path, file_content, file_status|
absolute_file_path = File.join(module_dir, relative_file_path)
case file_status
when :unmanage
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/pdk/module/convert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def module_path(relative_path)

before(:each) do
allow(update_manager).to receive(:changes?).and_return(false)
expect(template_dir).to receive(:render_new_module).with(anything).and_return(nil)
expect(template_dir).to receive(:render_new_module).and_return(nil)
allow(update_manager).to receive(:add_file).with(module_path('metadata.json'), anything)
end

Expand Down Expand Up @@ -496,9 +496,9 @@ def module_path(relative_path)
allow(PDK::Util::Git).to receive(:repo?).with(PDK::Util::TemplateURI.default_template_uri.metadata_format).and_return(true)
end

let(:default_uri) { "#{PDK::Util::TemplateURI.default_template_uri}##{PDK::Util::TemplateURI.default_template_ref}" }

it { is_expected.to eq(PDK::Util::TemplateURI.new(default_uri)) }
it do
is_expected.to eq(PDK::Util::TemplateURI.new(options))
end
end
end

Expand Down