summaryrefslogtreecommitdiff
path: root/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
blob: 35a856802c2e4dde5ac6573dbb2921a383288b88 (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::GithubImport::Stage::FinishImportWorker do
  let(:project) { create(:project) }
  let(:worker) { described_class.new }

  describe '#perform' do
    it 'marks the import as finished' do
      expect(project).to receive(:after_import)
      expect(worker).to receive(:report_import_time).with(project)

      worker.import(double(:client), project)
    end
  end

  describe '#report_import_time' do
    it 'reports the total import time' do
      expect(worker.histogram)
        .to receive(:observe)
        .with({ project: project.path_with_namespace }, a_kind_of(Numeric))
        .and_call_original

      expect(worker.counter)
        .to receive(:increment)
        .and_call_original

      expect(worker.logger).to receive(:info).with(an_instance_of(String))

      worker.report_import_time(project)
    end
  end
end