summaryrefslogtreecommitdiff
path: root/spec/uploaders/ci/pipeline_artifact_uploader_spec.rb
blob: 0630e9f6546e76266845f8e68c40d4a9d8da9db1 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::PipelineArtifactUploader do
  let(:pipeline_artifact) { create(:ci_pipeline_artifact) }
  let(:uploader) { described_class.new(pipeline_artifact, :file) }

  subject { uploader }

  it_behaves_like "builds correct paths",
                  store_dir: %r[\h{2}/\h{2}/\h{64}/pipelines/\d+/artifacts/\d+],
                  cache_dir: %r[artifacts/tmp/cache],
                  work_dir: %r[artifacts/tmp/work]

  context 'when object store is REMOTE' do
    before do
      stub_artifacts_object_storage(described_class)
    end

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

    it_behaves_like 'builds correct paths', store_dir: %r[\h{2}/\h{2}/\h{64}/pipelines/\d+/artifacts/\d+]
  end

  context 'when file is stored in valid local_path' do
    let(:file) do
      fixture_file_upload('spec/fixtures/pipeline_artifacts/code_coverage.json', 'application/json')
    end

    before do
      uploader.store!(file)
    end

    subject { uploader.file.path }

    it { is_expected.to match(%r[#{uploader.root}/#{uploader.class.base_dir}\h{2}/\h{2}/\h{64}/pipelines/#{pipeline_artifact.pipeline_id}/artifacts/#{pipeline_artifact.id}/code_coverage.json]) }
  end
end