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

migration_service_spec.rb « hashed_storage « projects « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f3ac26e776139cc9ab9cc0d268562e39815a0848 (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 'spec_helper'

describe Projects::HashedStorage::MigrationService do
  let(:project) { create(:project, :empty_repo, :wiki_repo, :legacy_storage) }
  let(:logger) { double }

  subject(:service) { described_class.new(project, project.full_path, logger: logger) }

  describe '#execute' do
    context 'repository migration' do
      let(:repository_service) do
        Projects::HashedStorage::MigrateRepositoryService.new(project: project,
                                                              old_disk_path: project.full_path,
                                                              logger: logger)
      end

      it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do
        expect(service).to receive(:migrate_repository_service).and_return(repository_service)
        expect(repository_service).to receive(:execute)

        service.execute
      end

      it 'does not delegate migration if repository is already migrated' do
        project.storage_version = ::Project::LATEST_STORAGE_VERSION
        expect(Projects::HashedStorage::MigrateRepositoryService).not_to receive(:new)

        service.execute
      end
    end

    context 'attachments migration' do
      let(:attachments_service) do
        Projects::HashedStorage::MigrateAttachmentsService.new(project: project,
                                                               old_disk_path: project.full_path,
                                                               logger: logger)
      end

      it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do
        expect(service).to receive(:migrate_attachments_service).and_return(attachments_service)
        expect(attachments_service).to receive(:execute)

        service.execute
      end

      it 'does not delegate migration if attachments are already migrated' do
        project.storage_version = ::Project::LATEST_STORAGE_VERSION
        expect(Projects::HashedStorage::MigrateAttachmentsService).not_to receive(:new)

        service.execute
      end
    end
  end
end