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

logger_spec.rb « artifacts « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7753cb0d25e30479d10a97ebe4ac0d21e599eb41 (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
57
58
59
60
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Artifacts::Logger do
  before do
    Gitlab::ApplicationContext.push(feature_category: 'test', caller_id: 'caller')
  end

  describe '.log_created' do
    it 'logs information about created artifact' do
      artifact = create(:ci_job_artifact, :archive)

      expect(Gitlab::AppLogger).to receive(:info).with(
        hash_including(
          message: 'Artifact created',
          job_artifact_id: artifact.id,
          size: artifact.size,
          type: artifact.file_type,
          build_id: artifact.job_id,
          project_id: artifact.project_id,
          'correlation_id' => an_instance_of(String),
          'meta.feature_category' => 'test',
          'meta.caller_id' => 'caller'
        )
      )

      described_class.log_created(artifact)
    end
  end

  describe '.log_deleted' do
    it 'logs information about deleted artifacts' do
      artifact_1 = create(:ci_job_artifact, :archive, :expired)
      artifact_2 = create(:ci_job_artifact, :archive)
      artifacts = [artifact_1, artifact_2]
      method = 'Foo#method'

      artifacts.each do |artifact|
        expect(Gitlab::AppLogger).to receive(:info).with(
          hash_including(
            message: 'Artifact deleted',
            job_artifact_id: artifact.id,
            expire_at: artifact.expire_at,
            size: artifact.size,
            type: artifact.file_type,
            build_id: artifact.job_id,
            project_id: artifact.project_id,
            method: method,
            'correlation_id' => an_instance_of(String),
            'meta.feature_category' => 'test',
            'meta.caller_id' => 'caller'
          )
        )
      end

      described_class.log_deleted(artifacts, method)
    end
  end
end