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

55 lines
1.5 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'rake_helper'
2021-09-04 01:27:46 +05:30
RSpec.describe 'gitlab:git rake tasks', :silence_stdout do
2018-11-08 19:23:39 +05:30
let(:base_path) { 'tmp/tests/default_storage' }
2018-11-18 11:00:15 +05:30
let!(:project) { create(:project, :repository) }
2018-05-09 12:01:36 +05:30
2018-03-17 18:26:18 +05:30
before do
Rake.application.rake_require 'tasks/gitlab/git'
stub_warn_user_is_not_gitlab
end
describe 'fsck' do
it 'outputs the integrity check for a repo' do
2018-11-18 11:00:15 +05:30
expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed integrity check for/).to_stdout
2018-03-17 18:26:18 +05:30
end
end
2021-03-08 18:12:59 +05:30
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
2018-03-17 18:26:18 +05:30
end