Commit c505a523 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Fixed few gitlab:check tasks that were failing with exception

parent e2b195b2
---
title: Some checks in `rake gitlab:check` were failling with 'undefined method `run_command`'
merge_request: 14469
author:
type: fixed
...@@ -9,7 +9,7 @@ module SystemCheck ...@@ -9,7 +9,7 @@ module SystemCheck
end end
def self.current_version def self.current_version
@current_version ||= Gitlab::VersionInfo.parse(run_command(%W(#{Gitlab.config.git.bin_path} --version))) @current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%W(#{Gitlab.config.git.bin_path} --version)))
end end
def check? def check?
......
...@@ -9,7 +9,7 @@ module SystemCheck ...@@ -9,7 +9,7 @@ module SystemCheck
end end
def self.current_version def self.current_version
@current_version ||= Gitlab::VersionInfo.parse(run_command(%w(ruby --version))) @current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%w(ruby --version)))
end end
def check? def check?
......
require 'spec_helper'
describe SystemCheck::BaseCheck do
context 'helpers on instance level' do
it 'responds to SystemCheck::Helpers methods' do
expect(subject).to respond_to :fix_and_rerun, :for_more_information, :see_installation_guide_section,
:finished_checking, :start_checking, :try_fixing_it, :sanitized_message, :should_sanitize?, :omnibus_gitlab?,
:sudo_gitlab
end
it 'responds to Gitlab::TaskHelpers methods' do
expect(subject).to respond_to :ask_to_continue, :os_name, :prompt, :run_and_match, :run_command,
:run_command!, :uid_for, :gid_for, :gitlab_user, :gitlab_user?, :warn_user_is_not_gitlab, :all_repos,
:repository_storage_paths_args, :user_home, :checkout_or_clone_version, :clone_repo, :checkout_version
end
end
end
...@@ -75,4 +75,24 @@ describe Gitlab::TaskHelpers do ...@@ -75,4 +75,24 @@ describe Gitlab::TaskHelpers do
subject.checkout_version(tag, clone_path) subject.checkout_version(tag, clone_path)
end end
end end
describe '#run_command' do
it 'runs command and return the output' do
expect(subject.run_command(%w(echo it works!))).to eq("it works!\n")
end
it 'returns empty string when command doesnt exist' do
expect(subject.run_command(%w(nonexistentcommand with arguments))).to eq('')
end
end
describe '#run_command!' do
it 'runs command and return the output' do
expect(subject.run_command!(%w(echo it works!))).to eq("it works!\n")
end
it 'returns and exception when command exit with non zero code' do
expect { subject.run_command!(['bash', '-c', 'exit 1']) }.to raise_error Gitlab::TaskFailedError
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment