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

component_file_uploader_spec.rb « debian « packages « uploaders « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: de60ec94acf7c7c4a3af792d3f85293bc6d72eea (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
# frozen_string_literal: true
require 'spec_helper'

RSpec.describe Packages::Debian::ComponentFileUploader do
  [:project, :group].each do |container_type|
    context "Packages::Debian::#{container_type.capitalize}ComponentFile" do
      let(:factory) { "debian_#{container_type}_component_file" }
      let(:component_file) { create(factory) } # rubocop:disable Rails/SaveBang
      let(:uploader) { described_class.new(component_file, :file) }
      let(:path) { Gitlab.config.packages.storage_path }

      subject { uploader }

      it_behaves_like "builds correct paths",
                      store_dir: %r[^\h{2}/\h{2}/\h{64}/debian_#{container_type}_component_file/\d+$],
                      cache_dir: %r[/packages/tmp/cache$],
                      work_dir: %r[/packages/tmp/work$]

      context 'object store is remote' do
        before do
          stub_package_file_object_storage
        end

        include_context 'with storage', described_class::Store::REMOTE

        it_behaves_like "builds correct paths",
                        store_dir: %r[^\h{2}/\h{2}/\h{64}/debian_#{container_type}_component_file/\d+$],
                        cache_dir: %r[/packages/tmp/cache$],
                        work_dir: %r[/packages/tmp/work$]
      end

      describe 'remote file' do
        let(:component_file) { create(factory, :object_storage) }

        context 'with object storage enabled' do
          before do
            stub_package_file_object_storage
          end

          it 'can store file remotely' do
            allow(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async)

            component_file

            expect(component_file.file_store).to eq(described_class::Store::REMOTE)
            expect(component_file.file.path).not_to be_blank
          end
        end
      end
    end
  end
end