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

u3d/install exit 1 when version not found. Fixes #343 #344

Merged
merged 1 commit into from
Feb 21, 2019
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
2 changes: 1 addition & 1 deletion lib/u3d/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def install(args: [], options: {})
cache_versions = cache_versions(os, offline: !options[:download])
version = interpret_latest(version, cache_versions)
unless cache_versions[version]
UI.error "No version '#{version}' was found in cache. Either it doesn't exist or u3d doesn't know about it yet. Try refreshing with 'u3d available -f'"
UI.crash! "No version '#{version}' was found in cache. Either it doesn't exist or u3d doesn't know about it yet. Try refreshing with 'u3d available -f'"
return
end

Expand Down
13 changes: 6 additions & 7 deletions spec/u3d/commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,11 @@
end

# request a non existing version number -> fail
# QUESTION: Raises an error instead of logging?
it 'logs an error when specifying a non existing version' do
it 'crashes error when specifying a non existing version' do
on_fake_os
with_fake_cache('fakeos' => { 'versions' => { '1.2.3f4' => 'fakeurl' } })

expect(U3dCore::UI).to receive(:error) {}
expect(U3dCore::UI).to receive(:crash!).with(/No version 'not.a.version'/)

U3d::Commands.install(
args: ['not.a.version'],
Expand Down Expand Up @@ -622,12 +621,12 @@
end
end

# request a non existing version number -> do nothing
it 'does not log an error when specifying a non existing version' do
# request a non existing version number -> crashes
it 'crashes when specifying a non existing version' do
on_fake_os
with_fake_cache('fakeos' => { 'versions' => { '1.2.3f4' => 'fakeurl' } })

expect(U3dCore::UI).to receive(:error).with(/No version 'not.a.version'/)
expect(U3dCore::UI).to receive(:crash!).with(/No version 'not.a.version'/)

U3d::Commands.install(
args: ['not.a.version'],
Expand Down Expand Up @@ -674,7 +673,7 @@
# reinstall a discovered version -> skipped, no credentials asked
it 'does not ask for credentials and does nothing when version is already present' do
on_linux
with_fake_cache('fakeos' => { 'versions' => { '1.2.3f4' => 'fakeurl' } })
with_fake_cache('linux' => { 'versions' => { '1.2.3f4' => 'fakeurl' } })
are_installed([fake_linux('1.2.3f4')])
expect_no_privileges_check
expect_no_install
Expand Down