summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/services/base_helm_service_shared_examples.rb
blob: fa76b95f7688550f84fbcc57eb41eef025d8cee5 (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
# frozen_string_literal: true

shared_examples 'logs kubernetes errors' do
  let(:error_hash) do
    {
      service: service.class.name,
      app_id: application.id,
      project_ids: application.cluster.project_ids,
      group_ids: [],
      error_code: error_code
    }
  end

  let(:logger_hash) do
    error_hash.merge(
      exception: error_name,
      message: error_message,
      backtrace: instance_of(Array)
    )
  end

  it 'logs into kubernetes.log and Sentry' do
    expect(service.send(:logger)).to receive(:error).with(hash_including(logger_hash))

    expect(Gitlab::Sentry).to receive(:track_acceptable_exception).with(
      error,
      extra: hash_including(error_hash)
    )

    service.execute
  end
end