diff options
author | Rémy Coutable <remy@rymai.me> | 2016-11-24 14:19:09 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-11-30 10:35:17 +0100 |
commit | a9c250eaddf758f99ac8c868dc86f4df0cc157f4 (patch) | |
tree | 8a6e338529341e89ca407ab865f9185028c5610d /spec/tasks | |
parent | fbbf177e3b604bebce3b10f8eea8920ff5606fca (diff) | |
download | gitlab-ce-a9c250eaddf758f99ac8c868dc86f4df0cc157f4.tar.gz |
Add #run_command! to task helpers to raise a TaskFailedError if status is not 0
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/gitlab/task_helpers_spec.rb | 22 | ||||
-rw-r--r-- | spec/tasks/gitlab/workhorse_rake_spec.rb | 8 |
2 files changed, 15 insertions, 15 deletions
diff --git a/spec/tasks/gitlab/task_helpers_spec.rb b/spec/tasks/gitlab/task_helpers_spec.rb index 2a2d4a39ba8..dccb3b4cf9a 100644 --- a/spec/tasks/gitlab/task_helpers_spec.rb +++ b/spec/tasks/gitlab/task_helpers_spec.rb @@ -15,7 +15,7 @@ describe 'gitlab:workhorse namespace rake task' do let(:tag) { 'v1.1.0' } before do FileUtils.rm_rf(clone_path) - allow_any_instance_of(Object).to receive(:run_command) + allow_any_instance_of(Object).to receive(:run_command!) expect_any_instance_of(Object).to receive(:reset_to_tag).with(tag) end @@ -27,7 +27,7 @@ describe 'gitlab:workhorse namespace rake task' do it 'clones the repo, retrieve the tag from origin, and checkout the tag' do expect(Dir).to receive(:chdir).and_call_original expect_any_instance_of(Object). - to receive(:run_command).with(%W[#{Gitlab.config.git.bin_path} clone -- #{repo} #{clone_path}]) { FileUtils.mkdir_p(clone_path) } # Fake the cloning + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} clone -- #{repo} #{clone_path}]) { FileUtils.mkdir_p(clone_path) } # Fake the cloning checkout_or_clone_tag(tag: tag, repo: repo, target_dir: clone_path) end @@ -41,9 +41,9 @@ describe 'gitlab:workhorse namespace rake task' do it 'fetch and checkout the tag' do expect(Dir).to receive(:chdir).twice.and_call_original expect_any_instance_of(Object). - to receive(:run_command).with(%W[#{Gitlab.config.git.bin_path} fetch --tags --quiet]) + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} fetch --tags --quiet]) expect_any_instance_of(Object). - to receive(:run_command).with(%W[#{Gitlab.config.git.bin_path} checkout --quiet #{tag}]) + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} checkout --quiet #{tag}]) checkout_or_clone_tag(tag: tag, repo: repo, target_dir: clone_path) end @@ -54,20 +54,20 @@ describe 'gitlab:workhorse namespace rake task' do let(:tag) { 'v1.1.0' } before do expect_any_instance_of(Object). - to receive(:run_command).with(%W[#{Gitlab.config.git.bin_path} reset --hard #{tag}]) + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} reset --hard #{tag}]) end context 'when the tag is not checked out locally' do before do - expect(Gitlab::Popen). - to receive(:popen).with(%W[#{Gitlab.config.git.bin_path} describe -- #{tag}]).and_return(['', 42]) + expect_any_instance_of(Object). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} describe -- #{tag}]).and_raise(Gitlab::TaskFailedError) end it 'fetch origin, ensure the tag exists, and resets --hard to the given tag' do expect_any_instance_of(Object). - to receive(:run_command).with(%W[#{Gitlab.config.git.bin_path} fetch origin]) + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} fetch origin]) expect_any_instance_of(Object). - to receive(:run_command).with(%W[#{Gitlab.config.git.bin_path} describe -- origin/#{tag}]).and_return(tag) + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} describe -- origin/#{tag}]).and_return(tag) reset_to_tag(tag) end @@ -75,8 +75,8 @@ describe 'gitlab:workhorse namespace rake task' do context 'when the tag is checked out locally' do before do - expect(Gitlab::Popen). - to receive(:popen).with(%W[#{Gitlab.config.git.bin_path} describe -- #{tag}]).and_return([tag, 0]) + expect_any_instance_of(Object). + to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} describe -- #{tag}]).and_return(tag) end it 'resets --hard to the given tag' do diff --git a/spec/tasks/gitlab/workhorse_rake_spec.rb b/spec/tasks/gitlab/workhorse_rake_spec.rb index c8ad004282a..87bc1b128bf 100644 --- a/spec/tasks/gitlab/workhorse_rake_spec.rb +++ b/spec/tasks/gitlab/workhorse_rake_spec.rb @@ -88,12 +88,12 @@ describe 'gitlab:workhorse namespace rake task' do context 'gmake is available' do before do expect_any_instance_of(Object).to receive(:checkout_or_clone_tag) - allow_any_instance_of(Object).to receive(:run_command).with(['gmake']).and_return(true) + allow_any_instance_of(Object).to receive(:run_command!).with(['gmake']).and_return(true) end it 'calls gmake in the gitlab-workhorse directory' do expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['/usr/bin/gmake', 0]) - expect_any_instance_of(Object).to receive(:run_command).with(['gmake']).and_return(true) + expect_any_instance_of(Object).to receive(:run_command!).with(['gmake']).and_return(true) run_rake_task('gitlab:workhorse:install', clone_path) end @@ -102,12 +102,12 @@ describe 'gitlab:workhorse namespace rake task' do context 'gmake is not available' do before do expect_any_instance_of(Object).to receive(:checkout_or_clone_tag) - allow_any_instance_of(Object).to receive(:run_command).with(['make']).and_return(true) + allow_any_instance_of(Object).to receive(:run_command!).with(['make']).and_return(true) end it 'calls make in the gitlab-workhorse directory' do expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['', 42]) - expect_any_instance_of(Object).to receive(:run_command).with(['make']).and_return(true) + expect_any_instance_of(Object).to receive(:run_command!).with(['make']).and_return(true) run_rake_task('gitlab:workhorse:install', clone_path) end |