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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
91117452
Commit
91117452
authored
Feb 28, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise an error if conditions are not fulfilled in archive method
parent
9ca8a5d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+2
-1
spec/lib/gitlab/ci/trace_spec.rb
spec/lib/gitlab/ci/trace_spec.rb
+14
-3
No files found.
lib/gitlab/ci/trace.rb
View file @
91117452
...
...
@@ -94,7 +94,8 @@ module Gitlab
end
def
archive!
return
if
trace_artifact
raise
'Already archived'
if
trace_artifact
raise
'Job is not finished yet'
unless
job
.
complete?
if
current_path
File
.
open
(
current_path
)
do
|
stream
|
...
...
spec/lib/gitlab/ci/trace_spec.rb
View file @
91117452
...
...
@@ -455,7 +455,7 @@ describe Gitlab::Ci::Trace do
context
'when job does not have trace artifact'
do
context
'when trace file stored in default path'
do
let!
(
:build
)
{
create
(
:ci_build
,
:trace_live
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:
success
,
:
trace_live
)
}
let!
(
:src_path
)
{
trace
.
read
{
|
s
|
return
s
.
path
}
}
let!
(
:src_checksum
)
{
Digest
::
SHA256
.
file
(
src_path
).
digest
}
...
...
@@ -481,7 +481,8 @@ describe Gitlab::Ci::Trace do
end
end
context
'when trace stored in database'
do
context
'when trace is stored in database'
do
let
(
:build
)
{
create
(
:ci_build
,
:success
)
}
let
(
:trace_content
)
{
IO
.
read
(
expand_fixture_path
(
'trace/sample_trace'
))
}
let!
(
:src_checksum
)
{
Digest
::
SHA256
.
digest
(
trace_content
)
}
...
...
@@ -519,9 +520,19 @@ describe Gitlab::Ci::Trace do
it
'does not archive'
do
expect_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
not_to
receive
(
:archive_stream!
)
expect
{
subject
}.
not_to
change
{
Ci
::
JobArtifact
.
count
}
expect
{
subject
}.
to
raise_error
(
'Already archived'
)
expect
(
build
.
job_artifacts_trace
.
file
.
exists?
).
to
be_truthy
end
end
context
'when job is not finished yet'
do
let!
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
)
}
it
'does not archive'
do
expect_any_instance_of
(
Gitlab
::
Ci
::
Trace
).
not_to
receive
(
:archive_stream!
)
expect
{
subject
}.
to
raise_error
(
'Job is not finished yet'
)
expect
(
build
.
trace
.
exist?
).
to
be_truthy
end
end
end
end
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