summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/gitlab/import_export/import_failure_service_shared_examples.rb
blob: 801be5ae9465c2356a9be55bc08880306a46de24 (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

RSpec.shared_examples 'log import failure' do |importable_column|
  it 'tracks error' do
    extra = {
              source: action,
              relation_key: relation_key,
              relation_index: relation_index,
              retry_count: retry_count
    }
    extra[importable_column] = importable.id

    expect(Gitlab::ErrorTracking).to receive(:track_exception).with(exception, extra)

    subject.log_import_failure(
      source: action,
      relation_key: relation_key,
      relation_index: relation_index,
      exception: exception,
      retry_count: retry_count)
  end

  it 'saves data to ImportFailure' do
    log_import_failure

    import_failure = ImportFailure.last

    aggregate_failures do
      expect(import_failure[importable_column]).to eq(importable.id)
      expect(import_failure.source).to eq(action)
      expect(import_failure.relation_key).to eq(relation_key)
      expect(import_failure.relation_index).to eq(relation_index)
      expect(import_failure.exception_class).to eq('StandardError')
      expect(import_failure.exception_message).to eq(standard_error_message)
      expect(import_failure.correlation_id_value).to eq(correlation_id)
      expect(import_failure.retry_count).to eq(retry_count)
    end
  end
end