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
88b5921a
Commit
88b5921a
authored
Mar 26, 2020
by
Maxime Orefice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose test reports with attachment on pipeline
parent
00286b2f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
5 deletions
+62
-5
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+7
-1
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+31
-4
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+6
-0
spec/factories/ci/job_artifacts.rb
spec/factories/ci/job_artifacts.rb
+10
-0
spec/factories/ci/pipelines.rb
spec/factories/ci/pipelines.rb
+8
-0
spec/fixtures/junit/junit_with_attachment.xml.gz
spec/fixtures/junit/junit_with_attachment.xml.gz
+0
-0
No files found.
app/controllers/projects/pipelines_controller.rb
View file @
88b5921a
...
...
@@ -172,9 +172,15 @@ class Projects::PipelinesController < Projects::ApplicationController
if
pipeline_test_report
==
:error
render
json:
{
status: :error_parsing_report
}
else
test_reports
=
if
params
[
:scope
]
==
"with_attachment"
pipeline_test_report
.
with_attachment!
else
pipeline_test_report
end
render
json:
TestReportSerializer
.
new
(
current_user:
@current_user
)
.
represent
(
pipeline_test_report
)
.
represent
(
test_reports
)
end
end
end
...
...
spec/controllers/projects/pipelines_controller_spec.rb
View file @
88b5921a
...
...
@@ -788,6 +788,28 @@ describe Projects::PipelinesController do
expect
(
json_response
[
'status'
]).
to
eq
(
'error_parsing_report'
)
end
end
context
'when test_report contains attachment and scope is with_attachment as a URL param'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:with_test_reports_attachment
,
project:
project
)
}
it
'returns a test reports with attachment'
do
get_test_report_json
(
scope:
'with_attachment'
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
"test_suites"
]).
to
be_present
end
end
context
'when test_report does not contain attachment and scope is with_attachment as a URL param'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:with_test_reports
,
project:
project
)
}
it
'returns a test reports with empty values'
do
get_test_report_json
(
scope:
'with_attachment'
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
"test_suites"
]).
to
be_empty
end
end
end
context
'when feature is disabled'
do
...
...
@@ -805,13 +827,18 @@ describe Projects::PipelinesController do
end
end
def
get_test_report_json
get
:test_report
,
params:
{
def
get_test_report_json
(
**
args
)
params
=
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
pipeline
.
id
},
format: :json
}
params
.
merge!
(
args
)
if
args
get
:test_report
,
params:
params
,
format: :json
end
def
clear_controller_memoization
...
...
spec/factories/ci/builds.rb
View file @
88b5921a
...
...
@@ -311,6 +311,12 @@ FactoryBot.define do
end
end
trait
:test_reports_with_attachment
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
create
(
:ci_job_artifact
,
:junit_with_attachment
,
job:
build
)
end
end
trait
:coverage_reports
do
after
(
:build
)
do
|
build
|
build
.
job_artifacts
<<
create
(
:ci_job_artifact
,
:cobertura
,
job:
build
)
...
...
spec/factories/ci/job_artifacts.rb
View file @
88b5921a
...
...
@@ -99,6 +99,16 @@ FactoryBot.define do
end
end
trait
:junit_with_attachment
do
file_type
{
:junit
}
file_format
{
:gzip
}
after
(
:build
)
do
|
artifact
,
evaluator
|
artifact
.
file
=
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/junit/junit_with_attachment.xml.gz'
),
'application/x-gzip'
)
end
end
trait
:junit_with_ant
do
file_type
{
:junit
}
file_format
{
:gzip
}
...
...
spec/factories/ci/pipelines.rb
View file @
88b5921a
...
...
@@ -67,6 +67,14 @@ FactoryBot.define do
end
end
trait
:with_test_reports_attachment
do
status
{
:success
}
after
(
:build
)
do
|
pipeline
,
evaluator
|
pipeline
.
builds
<<
build
(
:ci_build
,
:test_reports_with_attachment
,
pipeline:
pipeline
,
project:
pipeline
.
project
)
end
end
trait
:with_coverage_reports
do
status
{
:success
}
...
...
spec/fixtures/junit/junit_with_attachment.xml.gz
0 → 100644
View file @
88b5921a
File added
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