diff options
author | Robert Speicher <rspeicher@gmail.com> | 2018-07-03 17:20:51 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2018-07-03 17:20:51 -0500 |
commit | f5da4815a50ee3551c7330b85dc3c209e0fd0d57 (patch) | |
tree | 68788731eeed43a80bef3d35b92ae47edfa816eb | |
parent | 26998c68c936f183ead1a84e404a61160fc646f7 (diff) | |
download | gitlab-ce-f5da4815a50ee3551c7330b85dc3c209e0fd0d57.tar.gz |
Speed up spec/tasks/gitlab/git_rake_spec.rb
Because no Git repository was actually created at the temporary path we
were using, `git fsck` would traverse up until it found a repository,
which in our case was the CE or EE repository.
-rw-r--r-- | spec/tasks/gitlab/git_rake_spec.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb index 1efaecc63a5..d0263ad9a37 100644 --- a/spec/tasks/gitlab/git_rake_spec.rb +++ b/spec/tasks/gitlab/git_rake_spec.rb @@ -1,15 +1,20 @@ require 'rake_helper' describe 'gitlab:git rake tasks' do + let(:base_path) { 'tmp/tests/default_storage' } + before(:all) do @default_storage_hash = Gitlab.config.repositories.storages.default.to_h end before do 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_any_instance_of(String).to receive(:color) { |string, _color| string } @@ -17,7 +22,7 @@ describe 'gitlab:git rake tasks' do end after do - FileUtils.rm_rf(Settings.absolute('tmp/tests/default_storage')) + FileUtils.rm_rf(Settings.absolute(base_path)) end describe 'fsck' do @@ -26,14 +31,14 @@ describe 'gitlab:git rake tasks' do end 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 end 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.touch(Settings.absolute('tmp/tests/default_storage/@hashed/1/2/test.git/refs/heads/blah.lock')) + FileUtils.mkdir_p(Settings.absolute("#{base_path}/@hashed/1/2/test.git/refs/heads")) + 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 end |