debian-mirror-gitlab/spec/tasks/gitlab/workhorse_rake_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
2.1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'rake_helper'
2021-09-04 01:27:46 +05:30
RSpec.describe 'gitlab:workhorse namespace rake task', :silence_stdout do
2017-08-17 22:00:37 +05:30
before :all do
Rake.application.rake_require 'tasks/gitlab/workhorse'
end
describe 'install' do
let(:repo) { 'https://gitlab.com/gitlab-org/gitlab-workhorse.git' }
2021-02-22 17:27:13 +05:30
let(:clone_path) { Dir.mktmpdir('gitlab:workhorse:install-rake-test') }
let(:workhorse_source) { Rails.root.join('workhorse').to_s }
after do
FileUtils.rm_rf(clone_path)
end
2017-08-17 22:00:37 +05:30
context 'no dir given' do
it 'aborts and display a help message' do
# avoid writing task output to spec progress
allow($stderr).to receive :write
expect { run_rake_task('gitlab:workhorse:install') }.to raise_error /Please specify the directory where you want to install gitlab-workhorse/
end
end
2021-02-22 17:27:13 +05:30
context 'when an underlying Git command fails' do
2017-08-17 22:00:37 +05:30
it 'aborts and display a help message' do
2018-03-17 18:26:18 +05:30
expect(main_object)
2017-09-10 17:25:29 +05:30
.to receive(:checkout_or_clone_version).and_raise 'Git error'
2017-08-17 22:00:37 +05:30
expect { run_rake_task('gitlab:workhorse:install', clone_path) }.to raise_error 'Git error'
end
end
2021-02-22 17:27:13 +05:30
it 'clones the origin and creates a gitlab-workhorse binary' do
FileUtils.rm_rf(clone_path)
Dir.mktmpdir('fake-workhorse-origin') do |workhorse_origin|
[
%W[git init -q #{workhorse_origin}],
%W[git -C #{workhorse_origin} checkout -q -b workhorse-move-notice],
%W[touch #{workhorse_origin}/proof-that-repo-got-cloned],
%W[git -C #{workhorse_origin} add .],
%W[git -C #{workhorse_origin} commit -q -m init],
%W[git -C #{workhorse_origin} checkout -q -b master]
].each do |cmd|
raise "#{cmd.join(' ')} failed" unless system(*cmd)
2017-08-17 22:00:37 +05:30
end
2021-02-22 17:27:13 +05:30
run_rake_task('gitlab:workhorse:install', clone_path, File.join(workhorse_origin, '.git'))
2017-08-17 22:00:37 +05:30
end
2021-02-22 17:27:13 +05:30
expect(File.exist?(File.join(clone_path, 'proof-that-repo-got-cloned'))).to be true
expect(File.executable?(File.join(clone_path, 'gitlab-workhorse'))).to be true
2017-08-17 22:00:37 +05:30
end
end
end