Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7d784019
Commit
7d784019
authored
Nov 25, 2021
by
Kassio Borges
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add line number and import_type to the import status API
Also, fix a typo on the endpoint description Changelog: changed
parent
b0bad997
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
13 deletions
+38
-13
lib/api/entities/project_import_failed_relation.rb
lib/api/entities/project_import_failed_relation.rb
+1
-0
lib/api/entities/project_import_status.rb
lib/api/entities/project_import_status.rb
+1
-0
lib/api/project_import.rb
lib/api/project_import.rb
+1
-1
spec/factories/import_failures.rb
spec/factories/import_failures.rb
+2
-0
spec/lib/api/entities/project_import_failed_relation_spec.rb
spec/lib/api/entities/project_import_failed_relation_spec.rb
+2
-1
spec/lib/api/entities/project_import_status_spec.rb
spec/lib/api/entities/project_import_status_spec.rb
+31
-11
No files found.
lib/api/entities/project_import_failed_relation.rb
View file @
7d784019
...
...
@@ -10,6 +10,7 @@ module API
end
expose
:relation_key
,
as: :relation_name
expose
:relation_index
,
as: :line_number
end
end
end
lib/api/entities/project_import_status.rb
View file @
7d784019
...
...
@@ -4,6 +4,7 @@ module API
module
Entities
class
ProjectImportStatus
<
ProjectIdentity
expose
:import_status
expose
:import_type
expose
:correlation_id
do
|
project
,
_options
|
project
.
import_state
&
.
correlation_id
end
...
...
lib/api/project_import.rb
View file @
7d784019
...
...
@@ -107,7 +107,7 @@ module API
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
desc
'Get a project
ex
port status'
do
desc
'Get a project
im
port status'
do
detail
'This feature was introduced in GitLab 10.6.'
success
Entities
::
ProjectImportStatus
end
...
...
spec/factories/import_failures.rb
View file @
7d784019
...
...
@@ -10,6 +10,8 @@ FactoryBot.define do
exception_class
{
'RuntimeError'
}
exception_message
{
'Something went wrong'
}
source
{
'method_call'
}
relation_key
{
'issues'
}
relation_index
{
1
}
correlation_id_value
{
SecureRandom
.
uuid
}
trait
:hard_failure
do
...
...
spec/lib/api/entities/project_import_failed_relation_spec.rb
View file @
7d784019
...
...
@@ -16,7 +16,8 @@ RSpec.describe API::Entities::ProjectImportFailedRelation do
exception_class:
import_failure
.
exception_class
,
exception_message:
nil
,
relation_name:
import_failure
.
relation_key
,
source:
import_failure
.
source
source:
import_failure
.
source
,
line_number:
import_failure
.
relation_index
)
end
end
...
...
spec/lib/api/entities/project_import_status_spec.rb
View file @
7d784019
...
...
@@ -2,17 +2,18 @@
require
'spec_helper'
RSpec
.
describe
API
::
Entities
::
ProjectImportStatus
do
RSpec
.
describe
API
::
Entities
::
ProjectImportStatus
,
:aggregate_failures
do
describe
'#as_json'
do
subject
{
entity
.
as_json
}
let
(
:correlation_id
)
{
'cid'
}
context
'when no import state exists'
do
let
(
:entity
)
{
described_class
.
new
(
build
(
:project
))
}
let
(
:entity
)
{
described_class
.
new
(
build
(
:project
,
import_type:
'import_type'
))
}
it
'includes basic fields and no failures'
do
expect
(
subject
[
:import_status
]).
to
eq
(
'none'
)
expect
(
subject
[
:import_type
]).
to
eq
(
'import_type'
)
expect
(
subject
[
:correlation_id
]).
to
be_nil
expect
(
subject
[
:import_error
]).
to
be_nil
expect
(
subject
[
:failed_relations
]).
to
eq
([])
...
...
@@ -20,11 +21,12 @@ RSpec.describe API::Entities::ProjectImportStatus do
end
context
'when import has not finished yet'
do
let
(
:project
)
{
create
(
:project
,
:import_scheduled
,
import_correlation_id:
correlation_id
)
}
let
(
:entity
)
{
described_class
.
new
(
project
)
}
let
(
:project
)
{
create
(
:project
,
:import_scheduled
,
import_
type:
'import_type'
,
import_
correlation_id:
correlation_id
)
}
let
(
:entity
)
{
described_class
.
new
(
project
,
import_type:
'import_type'
)
}
it
'includes basic fields and no failures'
,
:aggregate_failures
do
it
'includes basic fields and no failures'
do
expect
(
subject
[
:import_status
]).
to
eq
(
'scheduled'
)
expect
(
subject
[
:import_type
]).
to
eq
(
'import_type'
)
expect
(
subject
[
:correlation_id
]).
to
eq
(
correlation_id
)
expect
(
subject
[
:import_error
]).
to
be_nil
expect
(
subject
[
:failed_relations
]).
to
eq
([])
...
...
@@ -32,25 +34,43 @@ RSpec.describe API::Entities::ProjectImportStatus do
end
context
'when import has finished with failed relations'
do
let
(
:project
)
{
create
(
:project
,
:import_finished
,
import_correlation_id:
correlation_id
)
}
let
(
:project
)
{
create
(
:project
,
:import_finished
,
import_
type:
'import_type'
,
import_
correlation_id:
correlation_id
)
}
let
(
:entity
)
{
described_class
.
new
(
project
)
}
it
'includes basic fields with failed relations'
,
:aggregate_failures
do
create
(
:import_failure
,
:hard_failure
,
project:
project
,
correlation_id_value:
correlation_id
)
it
'includes basic fields with failed relations'
do
create
(
:import_failure
,
:hard_failure
,
project:
project
,
correlation_id_value:
correlation_id
,
relation_key:
'issues'
,
relation_index:
1
)
# Doesn't show soft failures
create
(
:import_failure
,
:soft_failure
)
expect
(
subject
[
:import_status
]).
to
eq
(
'finished'
)
expect
(
subject
[
:import_type
]).
to
eq
(
'import_type'
)
expect
(
subject
[
:correlation_id
]).
to
eq
(
correlation_id
)
expect
(
subject
[
:import_error
]).
to
be_nil
expect
(
subject
[
:failed_relations
]).
not_to
be_empty
expect
(
subject
[
:failed_relations
].
length
).
to
eq
(
1
)
failure
=
subject
[
:failed_relations
].
last
expect
(
failure
[
:exception_class
]).
to
eq
(
'RuntimeError'
)
expect
(
failure
[
:source
]).
to
eq
(
'method_call'
)
expect
(
failure
[
:relation_name
]).
to
eq
(
'issues'
)
expect
(
failure
[
:line_number
]).
to
eq
(
1
)
end
end
context
'when import has failed'
do
let
(
:project
)
{
create
(
:project
,
:import_failed
,
import_correlation_id:
correlation_id
,
import_last_error:
'error'
)
}
let
(
:project
)
{
create
(
:project
,
:import_failed
,
import_
type:
'import_type'
,
import_
correlation_id:
correlation_id
,
import_last_error:
'error'
)
}
let
(
:entity
)
{
described_class
.
new
(
project
)
}
it
'includes basic fields with import error'
,
:aggregate_failures
do
it
'includes basic fields with import error'
do
expect
(
subject
[
:import_status
]).
to
eq
(
'failed'
)
expect
(
subject
[
:import_type
]).
to
eq
(
'import_type'
)
expect
(
subject
[
:correlation_id
]).
to
eq
(
correlation_id
)
expect
(
subject
[
:import_error
]).
to
eq
(
'error'
)
expect
(
subject
[
:failed_relations
]).
to
eq
([])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment