Skip to content
Snippets Groups Projects
Commit ecc9538e authored by Tetiana Zavediuk's avatar Tetiana Zavediuk Committed by Peter Leitzen
Browse files

Add private endpoint to show github import errors

Add private endpoint with paginated list of GitHub project import errors
for each particular entity.

Details: #388549

Changelog: added
parent 573defa9
No related branches found
No related tags found
2 merge requests!122597doc/gitaly: Remove references to removed metrics,!117133Add private endpoint to show github import errors
Showing
with 648 additions and 20 deletions
......@@ -91,6 +91,21 @@ def realtime_changes
render json: Import::GithubRealtimeRepoSerializer.new.represent(already_added_projects)
end
def failures
project = Project.imported_from(provider_name).find(params[:project_id])
unless project.import_finished?
return render status: :bad_request, json: {
message: _('The import is not complete.')
}
end
failures = project.import_failures.with_external_identifiers
serializer = Import::GithubFailureSerializer.new.with_pagination(request, response)
render json: serializer.represent(failures)
end
def cancel
project = Project.imported_from(provider_name).find(params[:project_id])
result = Import::Github::CancelProjectImportService.new(project, current_user).execute
......
......@@ -8,6 +8,8 @@ class ImportFailure < ApplicationRecord
validates :group, presence: true, unless: :project
validates :external_identifiers, json_schema: { filename: "import_failure_external_identifiers" }
scope :with_external_identifiers, -> { where.not(external_identifiers: {}) }
# Returns any `import_failures` for relations that were unrecoverable errors or failed after
# several retries. An import can be successful even if some relations failed to import correctly.
# A retry_count of 0 indicates that either no retries were attempted, or they were exceeded.
......
# frozen_string_literal: true
module Import
class GithubFailureEntity < Grape::Entity
expose :type do |failure|
failure.external_identifiers['object_type']
end
expose :title do |failure|
title(failure)
end
expose :provider_url do |failure|
build_url(failure)
end
expose :details do
expose :exception_class
expose :exception_message
expose :correlation_id_value
expose :source
expose :created_at
expose :github_identifiers do
with_options(expose_nil: false) do
expose(:object_type) { |failure| failure.external_identifiers['object_type'] }
expose(:id) { |failure| failure.external_identifiers['id'] }
expose(:db_id) { |failure| failure.external_identifiers['db_id'] }
expose(:iid) { |failure| failure.external_identifiers['iid'] }
expose(:title) { |failure| failure.external_identifiers['title'] }
expose(:login) { |failure| failure.external_identifiers['login'] }
expose(:event) { |failure| failure.external_identifiers['event'] }
expose(:merge_request_id) { |failure| failure.external_identifiers['merge_request_id'] }
expose(:merge_request_iid) { |failure| failure.external_identifiers['merge_request_iid'] }
expose(:requested_reviewers) { |failure| failure.external_identifiers['requested_reviewers'] }
expose(:note_id) { |failure| failure.external_identifiers['note_id'] }
expose(:noteable_type) { |failure| failure.external_identifiers['noteable_type'] }
expose(:noteable_iid) { |failure| failure.external_identifiers['noteable_iid'] }
expose(:issuable_type) { |failure| failure.external_identifiers['issuable_type'] }
expose(:issuable_iid) { |failure| failure.external_identifiers['issuable_iid'] }
expose(:review_id) { |failure| failure.external_identifiers['review_id'] }
expose(:tag) { |failure| failure.external_identifiers['tag'] }
expose(:oid) { |failure| failure.external_identifiers['oid'] }
expose(:size) { |failure| failure.external_identifiers['size'] }
end
end
end
private
# rubocop:disable Metrics/CyclomaticComplexity
def title(failure)
gh_identifiers = failure.external_identifiers
case gh_identifiers['object_type']
when 'pull_request', 'issue', 'label', 'milestone'
gh_identifiers['title']
when 'pull_request_merged_by'
format(s_("GithubImporter|Pull request %{pull_request_iid} merger"), pull_request_iid: gh_identifiers['iid'])
when 'pull_request_review_request'
format(
s_("GithubImporter|Pull request %{pull_request_iid} review request"),
pull_request_iid: gh_identifiers['merge_request_iid']
)
when 'pull_request_review'
format(s_("GithubImporter|Pull request review %{review_id}"), review_id: gh_identifiers['review_id'])
when 'collaborator'
gh_identifiers['login']
when 'protected_branch'
gh_identifiers['id']
when 'issue_event'
gh_identifiers['event']
when 'release'
gh_identifiers['tag']
when 'note'
format(
s_("GithubImporter|%{noteable_type} comment %{note_id}"),
noteable_type: gh_identifiers['noteable_type'],
note_id: gh_identifiers['note_id']
)
when 'diff_note'
format(s_("GithubImporter|Pull request review comment %{note_id}"), note_id: gh_identifiers['note_id'])
when 'issue_attachment'
format(s_("GithubImporter|Issue %{issue_iid} attachment"), issue_iid: gh_identifiers['noteable_iid'])
when 'merge_request_attachment'
format(
s_("GithubImporter|Merge request %{merge_request_iid} attachment"),
merge_request_iid: gh_identifiers['noteable_iid']
)
when 'release_attachment'
format(s_("GithubImporter|Release %{tag} attachment"), tag: gh_identifiers['tag'])
when 'note_attachment'
s_('GithubImporter|Note attachment')
when 'lfs_object'
gh_identifiers['oid'].to_s
else
''
end
end
def build_url(failure)
project = failure.project
gh_identifiers = failure.external_identifiers
github_repo = project.import_source
host = host(project.import_url)
return '' unless host
case gh_identifiers['object_type']
when 'pull_request', 'pull_request_merged_by'
# https://github.com/OWNER/REPO/pull/1
"#{host}/#{github_repo}/pull/#{gh_identifiers['iid']}"
when 'pull_request_review_request'
# https://github.com/OWNER/REPO/pull/1
"#{host}/#{github_repo}/pull/#{gh_identifiers['merge_request_iid']}"
when 'pull_request_review'
# https://github.com/OWNER/REPO/pull/1#pullrequestreview-1219894643
"#{host}/#{github_repo}/pull/#{gh_identifiers['merge_request_iid']}" \
"#pullrequestreview-#{gh_identifiers['review_id']}"
when 'issue'
# https://github.com/OWNER/REPO/issues/1
"#{host}/#{github_repo}/issues/#{gh_identifiers['iid']}"
when 'collaborator'
# https://github.com/USER_NAME
"#{host}/#{gh_identifiers['login']}"
when 'protected_branch'
branch = escape(gh_identifiers['id'])
# https://github.com/OWNER/REPO/tree/BRANCH_NAME
"#{host}/#{github_repo}/tree/#{branch}"
when 'issue_event'
# https://github.com/OWNER/REPO/issues/1#event-8356623615
"#{host}/#{github_repo}/issues/#{gh_identifiers['issuable_iid']}#event-#{gh_identifiers['id']}"
when 'label'
label = escape(gh_identifiers['title'])
# https://github.com/OWNER/REPO/labels/bug
"#{host}/#{github_repo}/labels/#{label}"
when 'milestone'
# https://github.com/OWNER/REPO/milestone/1
"#{host}/#{github_repo}/milestone/#{gh_identifiers['iid']}"
when 'release', 'release_attachment'
tag = escape(gh_identifiers['tag'])
# https://github.com/OWNER/REPO/releases/tag/v1.0
"#{host}/#{github_repo}/releases/tag/#{tag}"
when 'note'
# https://github.com/OWNER/REPO/issues/2#issuecomment-1480755368
"#{host}/#{github_repo}/issues/#{gh_identifiers['noteable_iid']}#issuecomment-#{gh_identifiers['note_id']}"
when 'diff_note'
# https://github.com/OWNER/REPO/pull/1#discussion_r1050098241
"#{host}/#{github_repo}/pull/#{gh_identifiers['noteable_iid']}#discussion_r#{gh_identifiers['note_id']}"
when 'issue_attachment'
# https://github.com/OWNER/REPO/issues/1
"#{host}/#{github_repo}/issues/#{gh_identifiers['noteable_iid']}"
when 'merge_request_attachment'
# https://github.com/OWNER/REPO/pull/1
"#{host}/#{github_repo}/pull/#{gh_identifiers['noteable_iid']}"
when 'lfs_object', 'note_attachment'
# we can't build url to lfs objects and note attachments
''
else
''
end
end
# rubocop:enable Metrics/CyclomaticComplexity
def host(uri)
parsed_uri = URI.parse(uri)
"#{parsed_uri.scheme}://#{parsed_uri.hostname}"
rescue URI::InvalidURIError
nil
end
def escape(str)
CGI.escape(str)
end
end
end
# frozen_string_literal: true
module Import
class GithubFailureSerializer < BaseSerializer
include WithPagination
entity Import::GithubFailureEntity
end
end
......@@ -22,6 +22,7 @@
get :details
get :callback
get :realtime_changes
get :failures
post :cancel
post :cancel_all
get :counts
......
# frozen_string_literal: true
class AddExternalIdentifiersIndexToImportFailures < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
INDEX_NAME = 'index_import_failures_on_external_identifiers'
def up
add_concurrent_index :import_failures, :external_identifiers, name: INDEX_NAME,
where: "external_identifiers != '{}'"
end
def down
remove_concurrent_index_by_name :import_failures, INDEX_NAME
end
end
36c538abaeb4239d5cc0424ebe2ac2f01c427d4acdfaf849f181d066f658899e
\ No newline at end of file
......@@ -30843,6 +30843,8 @@ CREATE INDEX index_import_export_uploads_on_updated_at ON import_export_uploads
 
CREATE INDEX index_import_failures_on_correlation_id_value ON import_failures USING btree (correlation_id_value);
 
CREATE INDEX index_import_failures_on_external_identifiers ON import_failures USING btree (external_identifiers) WHERE (external_identifiers <> '{}'::jsonb);
CREATE INDEX index_import_failures_on_group_id_not_null ON import_failures USING btree (group_id) WHERE (group_id IS NOT NULL);
 
CREATE INDEX index_import_failures_on_project_id_and_correlation_id_value ON import_failures USING btree (project_id, correlation_id_value) WHERE (retry_count = 0);
......@@ -8,7 +8,6 @@ class ReviewRequestImporter
def initialize(review_request, project, client)
@review_request = review_request
@user_finder = UserFinder.new(project, client)
@issue_finder = IssuableFinder.new(project, client)
end
def execute
......
......@@ -120,7 +120,7 @@ def diff_position
def github_identifiers
{
note_id: note_id,
noteable_id: noteable_id,
noteable_iid: noteable_id,
noteable_type: noteable_type
}
end
......
......@@ -22,7 +22,7 @@ def initialize(attributes)
def github_identifiers
{
id: id,
iid: issuable_id,
issuable_iid: issuable_id,
event: event
}
end
......
......@@ -76,7 +76,7 @@ def discussion_id
def github_identifiers
{
note_id: note_id,
noteable_id: noteable_id,
noteable_iid: noteable_id,
noteable_type: noteable_type
}
end
......
......@@ -19824,6 +19824,9 @@ msgstr ""
msgid "Gitea Import"
msgstr ""
 
msgid "GithubImporter|%{noteable_type} comment %{note_id}"
msgstr ""
msgid "GithubImporter|Collaborators"
msgstr ""
 
......@@ -19839,12 +19842,21 @@ msgstr ""
msgid "GithubImporter|GitHub gists with more than 10 files must be manually migrated."
msgstr ""
 
msgid "GithubImporter|Issue %{issue_iid} attachment"
msgstr ""
msgid "GithubImporter|Issue links"
msgstr ""
 
msgid "GithubImporter|Merge request %{merge_request_iid} attachment"
msgstr ""
msgid "GithubImporter|Merge request links"
msgstr ""
 
msgid "GithubImporter|Note attachment"
msgstr ""
msgid "GithubImporter|Note links"
msgstr ""
 
......@@ -19860,9 +19872,24 @@ msgstr ""
msgid "GithubImporter|Please follow %{import_snippets_url} for more details."
msgstr ""
 
msgid "GithubImporter|Pull request %{pull_request_iid} merger"
msgstr ""
msgid "GithubImporter|Pull request %{pull_request_iid} review request"
msgstr ""
msgid "GithubImporter|Pull request review %{review_id}"
msgstr ""
msgid "GithubImporter|Pull request review comment %{note_id}"
msgstr ""
msgid "GithubImporter|Pull requests"
msgstr ""
 
msgid "GithubImporter|Release %{tag} attachment"
msgstr ""
msgid "GithubImporter|Release links"
msgstr ""
 
......@@ -44315,6 +44342,9 @@ msgstr ""
msgid "The import cannot be canceled because it is %{project_status}"
msgstr ""
 
msgid "The import is not complete."
msgstr ""
msgid "The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination."
msgstr ""
 
......@@ -385,6 +385,57 @@
end
end
describe "GET failures" do
let_it_be_with_reload(:project) { create(:project, import_type: 'github', import_status: :started, import_source: 'example/repo', import_url: 'https://fake.url') }
let!(:import_failure) do
create(:import_failure,
project: project,
source: 'Gitlab::GithubImport::Importer::PullRequestImporter',
external_identifiers: { iid: 2, object_type: 'pull_request', title: 'My Pull Request' }
)
end
context 'when import is not finished' do
it 'return bad_request' do
get :failures, params: { project_id: project.id }
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('The import is not complete.')
end
end
context 'when import is finished' do
before do
project.import_state.finish
end
it 'includes failure details in response' do
get :failures, params: { project_id: project.id }
expect(json_response[0]['type']).to eq('pull_request')
expect(json_response[0]['title']).to eq('My Pull Request')
expect(json_response[0]['provider_url']).to eq("https://fake.url/example/repo/pull/2")
expect(json_response[0]['details']['source']).to eq(import_failure.source)
end
it 'paginates records' do
issue_title = 'My Issue'
create(
:import_failure,
project: project,
source: 'Gitlab::GithubImport::Importer::IssueAndLabelLinksImporter',
external_identifiers: { iid: 3, object_type: 'issue', title: issue_title }
)
get :failures, params: { project_id: project.id, page: 2, per_page: 1 }
expect(json_response.size).to eq(1)
expect(json_response.first['title']).to eq(issue_title)
end
end
end
describe "POST cancel" do
let_it_be(:project) do
create(
......
......@@ -21,5 +21,9 @@
trait :soft_failure do
retry_count { 1 }
end
trait :github_import_failure do
external_identifiers { { iid: 2, object_type: 'pull_request', title: 'Implement cool feature' } }
end
end
end
......@@ -131,7 +131,7 @@
describe '#github_identifiers' do
it 'returns a hash with needed identifiers' do
expect(note.github_identifiers).to eq(
noteable_id: 42,
noteable_iid: 42,
noteable_type: 'MergeRequest',
note_id: 1
)
......
......@@ -158,7 +158,7 @@
it 'returns a hash with needed identifiers' do
expect(issue_event.github_identifiers).to eq(
id: 6501124486,
iid: 2,
issuable_iid: 2,
event: 'closed'
)
end
......
......@@ -43,6 +43,16 @@
it 'includes the note ID' do
expect(note.note_id).to eq(1)
end
describe '#github_identifiers' do
it 'returns a hash with needed identifiers' do
expect(note.github_identifiers).to eq(
noteable_iid: 42,
noteable_type: 'Issue',
note_id: 1
)
end
end
end
end
......@@ -103,18 +113,4 @@
expect(note.author).to be_nil
end
end
describe '#github_identifiers' do
it 'returns a hash with needed identifiers' do
github_identifiers = {
noteable_id: 42,
noteable_type: 'Issue',
note_id: 1
}
other_attributes = { something_else: '_something_else_' }
note = described_class.new(github_identifiers.merge(other_attributes))
expect(note.github_identifiers).to eq(github_identifiers)
end
end
end
......@@ -8,8 +8,13 @@
let_it_be(:correlation_id) { 'ABC' }
let_it_be(:hard_failure) { create(:import_failure, :hard_failure, project: project, correlation_id_value: correlation_id) }
let_it_be(:soft_failure) { create(:import_failure, :soft_failure, project: project, correlation_id_value: correlation_id) }
let_it_be(:github_import_failure) { create(:import_failure, :github_import_failure, project: project) }
let_it_be(:unrelated_failure) { create(:import_failure, project: project) }
it 'returns failures with external_identifiers' do
expect(ImportFailure.with_external_identifiers).to match_array([github_import_failure])
end
it 'returns failures for the given correlation ID' do
expect(ImportFailure.failures_by_correlation_id(correlation_id)).to match_array([hard_failure, soft_failure])
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Import::GithubFailureEntity, feature_category: :importers do
let(:project) { instance_double(Project, id: 123456, import_url: 'https://github.com/example/repo.git', import_source: 'example/repo') }
let(:source) { 'Gitlab::GithubImport::Importer::PullRequestImporter' }
let(:github_identifiers) { { 'iid' => 2, 'object_type' => 'pull_request', 'title' => 'Implement cool feature' } }
let(:import_failure) do
instance_double(
ImportFailure,
project: project,
exception_class: 'Some class',
exception_message: 'Something went wrong',
source: source,
correlation_id_value: '2ea9c4b8587b6df49f35a3fb703688aa',
external_identifiers: github_identifiers,
created_at: Time.current
)
end
let(:failure_details) do
{
exception_class: import_failure.exception_class,
exception_message: import_failure.exception_message,
correlation_id_value: import_failure.correlation_id_value,
source: import_failure.source,
github_identifiers: github_identifiers,
created_at: import_failure.created_at
}
end
subject(:entity) { described_class.new(import_failure).as_json.with_indifferent_access }
shared_examples 'import failure entity' do
it 'exposes required fields for import entity' do
expect(entity).to eq(
{
type: import_failure.external_identifiers['object_type'],
title: title,
provider_url: provider_url,
details: failure_details
}.with_indifferent_access
)
end
end
it 'exposes correct attributes' do
expect(entity.keys).to match_array(%w[type title provider_url details])
end
context 'with `pull_request` failure' do
it_behaves_like 'import failure entity' do
let(:title) { 'Implement cool feature' }
let(:provider_url) { 'https://github.com/example/repo/pull/2' }
end
end
context 'with `pull_request_merged_by` failure' do
before do
import_failure.external_identifiers.merge!({ 'object_type' => 'pull_request_merged_by' })
end
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::PullRequestMergedByImporter' }
let(:title) { 'Pull request 2 merger' }
let(:provider_url) { 'https://github.com/example/repo/pull/2' }
end
end
context 'with `pull_request_review_request` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::PullRequests::ReviewRequestImporter' }
let(:title) { 'Pull request 2 review request' }
let(:provider_url) { 'https://github.com/example/repo/pull/2' }
let(:github_identifiers) do
{
'merge_request_iid' => 2,
'requested_reviewers' => %w[alice bob],
'object_type' => 'pull_request_review_request'
}
end
end
end
context 'with `pull_request_review` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::PullRequestReviewImporter' }
let(:title) { 'Pull request review 123456' }
let(:provider_url) { 'https://github.com/example/repo/pull/2#pullrequestreview-123456' }
let(:github_identifiers) do
{
'merge_request_iid' => 2,
'review_id' => 123456,
'object_type' => 'pull_request_review'
}
end
end
end
context 'with `issue` failure' do
before do
import_failure.external_identifiers.merge!({ 'object_type' => 'issue' })
end
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::IssueAndLabelLinksImporter' }
let(:title) { 'Implement cool feature' }
let(:provider_url) { 'https://github.com/example/repo/issues/2' }
end
end
context 'with `collaborator` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::CollaboratorImporter' }
let(:title) { 'alice' }
let(:provider_url) { 'https://github.com/alice' }
let(:github_identifiers) do
{
'id' => 123456,
'login' => 'alice',
'object_type' => 'collaborator'
}
end
end
end
context 'with `protected_branch` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::ProtectedBranchImporter' }
let(:title) { 'main' }
let(:provider_url) { 'https://github.com/example/repo/tree/main' }
let(:github_identifiers) do
{
'id' => 'main',
'object_type' => 'protected_branch'
}
end
end
end
context 'with `issue_event` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::IssueEventImporter' }
let(:title) { 'closed' }
let(:provider_url) { 'https://github.com/example/repo/issues/2#event-123456' }
let(:github_identifiers) do
{
'id' => 123456,
'issuable_iid' => 2,
'event' => 'closed',
'object_type' => 'issue_event'
}
end
end
end
context 'with `label` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::LabelsImporter' }
let(:title) { 'bug' }
let(:provider_url) { 'https://github.com/example/repo/labels/bug' }
let(:github_identifiers) { { 'title' => 'bug', 'object_type' => 'label' } }
end
end
context 'with `milestone` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::MilestonesImporter' }
let(:title) { '1 release' }
let(:provider_url) { 'https://github.com/example/repo/milestone/1' }
let(:github_identifiers) { { 'iid' => 1, 'title' => '1 release', 'object_type' => 'milestone' } }
end
end
context 'with `release` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::ReleasesImporter' }
let(:title) { 'v1.0' }
let(:provider_url) { 'https://github.com/example/repo/releases/tag/v1.0' }
let(:github_identifiers) do
{
'tag' => 'v1.0',
'object_type' => 'release'
}
end
end
end
context 'with `note` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::NoteImporter' }
let(:title) { 'MergeRequest comment 123456' }
let(:provider_url) { 'https://github.com/example/repo/issues/2#issuecomment-123456' }
let(:github_identifiers) do
{
'note_id' => 123456,
'noteable_iid' => 2,
'noteable_type' => 'MergeRequest',
'object_type' => 'note'
}
end
end
end
context 'with `diff_note` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::DiffNoteImporter' }
let(:title) { 'Pull request review comment 123456' }
let(:provider_url) { 'https://github.com/example/repo/pull/2#discussion_r123456' }
let(:github_identifiers) do
{
'note_id' => 123456,
'noteable_iid' => 2,
'noteable_type' => 'MergeRequest',
'object_type' => 'diff_note'
}
end
end
end
context 'with `issue_attachment` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::NoteAttachmentsImporter' }
let(:title) { 'Issue 2 attachment' }
let(:provider_url) { 'https://github.com/example/repo/issues/2' }
let(:github_identifiers) do
{
'db_id' => 123456,
'noteable_iid' => 2,
'object_type' => 'issue_attachment'
}
end
end
end
context 'with `merge_request_attachment` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::NoteAttachmentsImporter' }
let(:title) { 'Merge request 2 attachment' }
let(:provider_url) { 'https://github.com/example/repo/pull/2' }
let(:github_identifiers) do
{
'db_id' => 123456,
'noteable_iid' => 2,
'object_type' => 'merge_request_attachment'
}
end
end
end
context 'with `release_attachment` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::NoteAttachmentsImporter' }
let(:title) { 'Release v1.0 attachment' }
let(:provider_url) { 'https://github.com/example/repo/releases/tag/v1.0' }
let(:github_identifiers) do
{
'db_id' => 123456,
'tag' => 'v1.0',
'object_type' => 'release_attachment'
}
end
end
end
context 'with `note_attachment` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::NoteAttachmentsImporter' }
let(:title) { 'Note attachment' }
let(:provider_url) { '' }
let(:github_identifiers) do
{
'db_id' => 123456,
'noteable_type' => 'Issue',
'object_type' => 'note_attachment'
}
end
end
end
context 'with `lfs_object` failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::LfsObjectImporter' }
let(:title) { '42' }
let(:provider_url) { '' }
let(:github_identifiers) do
{
'oid' => 42,
'size' => 123456,
'object_type' => 'lfs_object'
}
end
end
end
context 'with unknown failure' do
it_behaves_like 'import failure entity' do
let(:source) { 'Gitlab::GithubImport::Importer::NewObjectTypeImporter' }
let(:title) { '' }
let(:provider_url) { '' }
let(:github_identifiers) do
{
'id' => 123456,
'object_type' => 'new_object_type'
}
end
end
end
context 'with an invalid import_url' do
let(:project) { instance_double(Project, id: 123456, import_url: 'Invalid url', import_source: 'example/repo') }
it_behaves_like 'import failure entity' do
let(:title) { 'Implement cool feature' }
let(:provider_url) { '' }
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment