Commit 98eb0578 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-git-rake-spec-speed' into 'master'

Speed up spec/tasks/gitlab/git_rake_spec.rb

See merge request gitlab-org/gitlab-ce!20349
parents 4c1a2a9b f5da4815
require 'rake_helper' require 'rake_helper'
describe 'gitlab:git rake tasks' do describe 'gitlab:git rake tasks' do
let(:base_path) { 'tmp/tests/default_storage' }
before(:all) do before(:all) do
@default_storage_hash = Gitlab.config.repositories.storages.default.to_h @default_storage_hash = Gitlab.config.repositories.storages.default.to_h
end end
before do before do
Rake.application.rake_require 'tasks/gitlab/git' Rake.application.rake_require 'tasks/gitlab/git'
storages = { 'default' => Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge('path' => 'tmp/tests/default_storage')) } storages = { 'default' => Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge('path' => base_path)) }
path = Settings.absolute("#{base_path}/@hashed/1/2/test.git")
FileUtils.mkdir_p(path)
Gitlab::Popen.popen(%W[git -C #{path} init --bare])
FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git'))
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
allow_any_instance_of(String).to receive(:color) { |string, _color| string } allow_any_instance_of(String).to receive(:color) { |string, _color| string }
...@@ -17,7 +22,7 @@ describe 'gitlab:git rake tasks' do ...@@ -17,7 +22,7 @@ describe 'gitlab:git rake tasks' do
end end
after do after do
FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage')) FileUtils.rm_rf(Settings.absolute(base_path))
end end
describe 'fsck' do describe 'fsck' do
...@@ -26,14 +31,14 @@ describe 'gitlab:git rake tasks' do ...@@ -26,14 +31,14 @@ describe 'gitlab:git rake tasks' do
end end
it 'errors out about config.lock issues' do it 'errors out about config.lock issues' do
FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/config.lock')) FileUtils.touch(Settings.absolute("#{base_path}/@hashed/1/2/test.git/config.lock"))
expect { run_rake_task('gitlab:git:fsck') }.to output(/file exists\? ... yes/).to_stdout expect { run_rake_task('gitlab:git:fsck') }.to output(/file exists\? ... yes/).to_stdout
end end
it 'errors out about ref lock issues' do it 'errors out about ref lock issues' do
FileUtils.mkdir_p(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/refs/heads')) FileUtils.mkdir_p(Settings.absolute("#{base_path}/@hashed/1/2/test.git/refs/heads"))
FileUtils.touch(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/refs/heads/blah.lock')) FileUtils.touch(Settings.absolute("#{base_path}/@hashed/1/2/test.git/refs/heads/blah.lock"))
expect { run_rake_task('gitlab:git:fsck') }.to output(/Ref lock files exist:/).to_stdout expect { run_rake_task('gitlab:git:fsck') }.to output(/Ref lock files exist:/).to_stdout
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