diff options
Diffstat (limited to 'spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb')
-rw-r--r-- | spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb index 29578f9bf37..b18b5ce64d1 100644 --- a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb @@ -3,14 +3,15 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do - let(:project) { create(:project) } - let(:import_state) { create(:import_state, project: project) } + let_it_be(:project) { create(:project) } + let_it_be(:import_state) { create(:import_state, project: project) } + let(:worker) { described_class.new } + let(:importer) { double(:importer) } + let(:client) { double(:client) } describe '#import' do it 'imports all the pull requests' do - importer = double(:importer) - client = double(:client) waiter = Gitlab::JobWaiter.new(2, '123') expect(Gitlab::GithubImport::Importer::PullRequestsImporter) @@ -32,4 +33,22 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do worker.import(client, project) end end + + it 'raises an error' do + exception = StandardError.new('_some_error_') + + expect_next_instance_of(Gitlab::GithubImport::Importer::PullRequestsImporter) do |importer| + expect(importer).to receive(:execute).and_raise(exception) + end + expect(Gitlab::Import::ImportFailureService).to receive(:track) + .with( + project_id: project.id, + exception: exception, + error_source: described_class.name, + fail_import: true, + metrics: true + ).and_call_original + + expect { worker.import(client, project) }.to raise_error(StandardError) + end end |