Skip to content
Snippets Groups Projects
Commit 833a3f74 authored by Balasankar "Balu" C's avatar Balasankar "Balu" C
Browse files

Raise exception if version fetching command failed

parent 7f59a167
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,9 @@
def self.version(cmd, env: {})
result = do_shell_out(cmd, env: env)
result.stdout if result.exitstatus.zero?
raise "Execution of the command `#{cmd}` failed with a non-zero exit code (#{result.exitstatus})" unless result.exitstatus.zero?
result.stdout
end
end unless defined?(VersionHelper) # Prevent reloading in chefspec: https://github.com/sethvargo/chefspec/issues/562#issuecomment-74120922
......@@ -49,6 +49,8 @@
stub_command('/opt/gitlab/embedded/bin/psql --version').and_return("fake_version")
allow(VersionHelper).to receive(:version).and_call_original
allow(VersionHelper).to receive(:version).with('/opt/gitlab/embedded/bin/psql --version').and_return('fake_psql_version')
allow(VersionHelper).to receive(:version).with('cat /opt/gitlab/embedded/service/mattermost/VERSION').and_return('foobar')
allow(VersionHelper).to receive(:version).with(/-[-]?version/).and_return('foobar')
allow_any_instance_of(RedisHelper).to receive(:installed_version).and_return('3.2.12')
allow_any_instance_of(RedisHelper).to receive(:running_version).and_return('3.2.12')
stub_command('/sbin/init --version | grep upstart')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment