gitlab-org--gitlab-foss/spec/tasks/gitlab/git_rake_spec.rb

42 lines
1.6 KiB
Ruby
Raw Normal View History

2017-12-14 05:49:35 -05:00
require 'rake_helper'
describe 'gitlab:git rake tasks' do
before(:all) do
@default_storage_hash = Gitlab.config.repositories.storages.default.to_h
end
2017-12-14 05:49:35 -05:00
before do
Rake.application.rake_require 'tasks/gitlab/git'
storages = { 'default' => Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge('path' => 'tmp/tests/default_storage')) }
2017-12-14 05:49:35 -05:00
2018-01-04 05:02:43 -05:00
FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git'))
2017-12-14 08:53:34 -05:00
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
2018-01-04 05:02:43 -05:00
allow_any_instance_of(String).to receive(:color) { |string, _color| string }
2017-12-14 08:53:34 -05:00
stub_warn_user_is_not_gitlab
2017-12-14 05:49:35 -05:00
end
after do
FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage'))
end
describe 'fsck' do
2018-01-04 05:02:43 -05:00
it 'outputs the integrity check for a repo' do
2018-01-27 00:35:53 -05:00
expect { run_rake_task('gitlab:git:fsck') }.to output(%r{Performed Checking integrity at .*@hashed/1/2/test.git}).to_stdout
2017-12-14 05:49:35 -05:00
end
2018-01-03 09:32:16 -05:00
it 'errors out about config.lock issues' do
2018-01-04 05:02:43 -05:00
FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/config.lock'))
2018-01-03 09:32:16 -05:00
expect { run_rake_task('gitlab:git:fsck') }.to output(/file exists\? ... yes/).to_stdout
end
it 'errors out about ref lock issues' do
2018-01-04 05:02:43 -05:00
FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/refs/heads'))
FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/refs/heads/blah.lock'))
2018-01-03 09:32:16 -05:00
expect { run_rake_task('gitlab:git:fsck') }.to output(/Ref lock files exist:/).to_stdout
end
2017-12-14 05:49:35 -05:00
end
end