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

require 'spec_helper'

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

  describe '#perform' do
    it 'marks the import as finished and reports import statistics' do
      expect(project).to receive(:after_import)
      expect_next_instance_of(Gitlab::Import::Metrics) do |instance|
        expect(instance).to receive(:track_finished_import)
        expect(instance).to receive(:duration).and_return(3.005)
      end

      expect(Gitlab::GithubImport::Logger)
        .to receive(:info)
              .with(
                message: 'GitHub project import finished',
                import_stage: 'Gitlab::GithubImport::Stage::FinishImportWorker',
                object_counts: {
                  'fetched' => {},
                  'imported' => {}
                },
                project_id: project.id,
                duration_s: 3.01
              )

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