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-808) Fix to pdk update when there are sync.yml changes #431

Merged
merged 1 commit into from
Feb 21, 2018
Merged
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
8 changes: 1 addition & 7 deletions lib/pdk/cli/update.rb
Original file line number Diff line number Diff line change
@@ -25,13 +25,7 @@ module PDK::CLI

updater = PDK::Module::Update.new(opts)

if updater.current_version == updater.new_version
PDK.logger.info _('This module is already up to date with version %{version} of the template.') % {
version: updater.new_version,
}
else
updater.run
end
updater.run
end
end
end
7 changes: 7 additions & 0 deletions lib/pdk/module/update.rb
Original file line number Diff line number Diff line change
@@ -13,6 +13,13 @@ def run
print_summary
full_report('update_report.txt') unless update_manager.changes[:modified].empty?

if !update_manager.changes? && current_version == new_version
PDK.logger.info _('This module is already up to date with version %{version} of the template.') % {
version: new_version,
}
return
end

return if noop?

unless force?
12 changes: 0 additions & 12 deletions spec/unit/pdk/cli/update_spec.rb
Original file line number Diff line number Diff line change
@@ -57,17 +57,5 @@
expect { PDK::CLI.run(%w[update --noop --force]) }.to exit_nonzero
end
end

context 'and the module is already up to date' do
let(:current_version) { new_version }

it 'does not run the updater' do
expect(logger).to receive(:info).with(a_string_matching(%r{already up to date with version #{current_version}}i))
expect(PDK::Module::Update).to receive(:new).with({}).and_return(updater)
expect(updater).not_to receive(:run)

PDK::CLI.run(%w[update])
end
end
end
end
26 changes: 26 additions & 0 deletions spec/unit/pdk/module/update_spec.rb
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@
describe '#run' do
let(:instance) { described_class.new(options) }
let(:template_ref) { '1.3.2-0-g1234567' }
let(:changes) { true }

include_context 'with mock metadata'

@@ -55,12 +56,37 @@
allow(instance).to receive(:new_version).and_return('1.4.0')
allow(instance).to receive(:print_result)
allow(instance.update_manager).to receive(:sync_changes!)
allow(instance.update_manager).to receive(:changes?).and_return(changes)
end

after(:each) do
instance.run
end

context 'when the version is the same' do
let(:options) { { noop: true } }

before(:each) do
allow(instance).to receive(:current_version).and_return('1.4.0')
end

context 'but there are changes' do
let(:changes) { true }

it 'doesn\'t print message' do
expect(logger).not_to receive(:info).with(a_string_matching(%r{This module is already up to date with version 1.4.0 of the template}i))
end
end

context 'but there are no changes' do
let(:changes) { false }

it 'doesn\'t print message' do
expect(logger).to receive(:info).with(a_string_matching(%r{This module is already up to date with version 1.4.0 of the template}))
end
end
end

context 'when using the default template' do
let(:options) { { noop: true } }
let(:template_url) { PDK::Util.default_template_url }