2019-10-15 09:06:09 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-14 10:49:35 +00:00
|
|
|
require 'rake_helper'
|
|
|
|
|
2021-06-08 15:10:00 +00:00
|
|
|
RSpec.describe 'gitlab:git rake tasks', :silence_stdout do
|
2018-07-03 22:20:51 +00:00
|
|
|
let(:base_path) { 'tmp/tests/default_storage' }
|
2018-07-24 10:17:29 +00:00
|
|
|
let!(:project) { create(:project, :repository) }
|
2018-03-14 13:42:49 +00:00
|
|
|
|
2017-12-14 10:49:35 +00:00
|
|
|
before do
|
|
|
|
Rake.application.rake_require 'tasks/gitlab/git'
|
|
|
|
|
2017-12-14 13:53:34 +00:00
|
|
|
stub_warn_user_is_not_gitlab
|
2017-12-14 10:49:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'fsck' do
|
2018-01-04 10:02:43 +00:00
|
|
|
it 'outputs the integrity check for a repo' do
|
2018-07-24 10:17:29 +00:00
|
|
|
expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed integrity check for/).to_stdout
|
2018-01-03 14:32:16 +00:00
|
|
|
end
|
2017-12-14 10:49:35 +00:00
|
|
|
end
|
2021-01-11 09:10:46 +00:00
|
|
|
|
|
|
|
describe 'checksum_projects' do
|
|
|
|
it 'outputs the checksum for a repo' do
|
|
|
|
expected = /#{project.id},#{project.repository.checksum}/
|
|
|
|
|
|
|
|
expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'outputs blank checksum for no repo' do
|
|
|
|
no_repo = create(:project)
|
|
|
|
|
|
|
|
expected = /#{no_repo.id},$/
|
|
|
|
|
|
|
|
expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'outputs zeroes for empty repo' do
|
|
|
|
empty_repo = create(:project, :empty_repo)
|
|
|
|
|
|
|
|
expected = /#{empty_repo.id},0000000000000000000000000000000000000000/
|
|
|
|
|
|
|
|
expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'outputs errors' do
|
|
|
|
allow_next_found_instance_of(Project) do |project|
|
|
|
|
allow(project).to receive(:repo_exists?).and_raise('foo')
|
|
|
|
end
|
|
|
|
|
|
|
|
expected = /#{project.id},Ignored error: foo/
|
|
|
|
|
|
|
|
expect { run_rake_task('gitlab:git:checksum_projects') }.to output(expected).to_stdout
|
|
|
|
end
|
|
|
|
end
|
2017-12-14 10:49:35 +00:00
|
|
|
end
|