Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git_rake_spec.rb « gitlab « tasks « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4d89b126c9ec00870924d49027083312e4958f2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require 'rake_helper'

RSpec.describe 'gitlab:git rake tasks' do
  let(:base_path) { 'tmp/tests/default_storage' }
  let!(:project) { create(:project, :repository) }

  before do
    Rake.application.rake_require 'tasks/gitlab/git'

    allow_any_instance_of(String).to receive(:color) { |string, _color| string }

    stub_warn_user_is_not_gitlab
  end

  describe 'fsck' do
    it 'outputs the integrity check for a repo' do
      expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed integrity check for/).to_stdout
    end
  end

  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
end