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
9bdb4b17
Commit
9bdb4b17
authored
Jul 06, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec
parent
18238cac
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
6 deletions
+118
-6
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+38
-6
spec/support/shared_examples/ci_trace_shared_examples.rb
spec/support/shared_examples/ci_trace_shared_examples.rb
+80
-0
No files found.
spec/models/ci/build_spec.rb
View file @
9bdb4b17
...
...
@@ -514,6 +514,22 @@ describe Ci::Build do
end
end
describe
'#has_old_trace?'
do
subject
{
build
.
has_old_trace?
}
context
'when old trace exists'
do
before
do
build
.
update_column
(
:trace
,
'old trace'
)
end
it
{
is_expected
.
to
be_truthy
}
end
context
'when old trace does not exist'
do
it
{
is_expected
.
to
be_falsy
}
end
end
describe
'#trace='
do
it
"expect to fail trace="
do
expect
{
build
.
trace
=
"new"
}.
to
raise_error
(
NotImplementedError
)
...
...
@@ -533,16 +549,32 @@ describe Ci::Build do
end
describe
'#erase_old_trace!'
do
subject
{
build
.
send
(
:read_attribute
,
:trace
)
}
subject
{
build
.
erase_old_trace!
}
context
'when old trace exists'
do
before
do
build
.
send
(
:write_attribute
,
:trace
,
'old trace'
)
build
.
update_column
(
:trace
,
'old trace'
)
end
it
"expect to receive data from databas
e"
do
build
.
erase_old_trace!
it
"erases old trac
e"
do
subject
is_expected
.
to
be_nil
expect
(
build
.
old_trace
).
to
be_nil
end
it
"executes UPDATE query"
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
log
.
select
{
|
l
|
l
.
match?
(
/UPDATE.*ci_builds/
)
}.
count
).
to
eq
(
1
)
end
end
context
'when old trace does not exist'
do
it
'does not execute UPDATE query'
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
log
.
select
{
|
l
|
l
.
match?
(
/UPDATE.*ci_builds/
)
}.
count
).
to
eq
(
0
)
end
end
end
...
...
spec/support/shared_examples/ci_trace_shared_examples.rb
View file @
9bdb4b17
...
...
@@ -589,6 +589,55 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
end
describe
'#erase!'
do
subject
{
trace
.
erase!
}
context
'when it is a live trace'
do
context
'when trace is stored in database'
do
let
(
:build
)
{
create
(
:ci_build
)
}
before
do
build
.
update_column
(
:trace
,
'sample trace'
)
end
it
{
expect
(
trace
.
raw
).
not_to
be_nil
}
it
"removes trace"
do
subject
expect
(
trace
.
raw
).
to
be_nil
end
end
context
'when trace is stored in file storage'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace_live
)
}
it
{
expect
(
trace
.
raw
).
not_to
be_nil
}
it
"removes trace"
do
subject
expect
(
trace
.
raw
).
to
be_nil
end
end
end
context
'when it is an archived trace'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace_artifact
)
}
it
"has trace at first"
do
expect
(
trace
.
raw
).
not_to
be_nil
end
it
"removes trace"
do
subject
build
.
reload
expect
(
trace
.
raw
).
to
be_nil
end
end
end
end
shared_examples_for
'trace with enabled live trace feature'
do
...
...
@@ -776,4 +825,35 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
end
describe
'#erase!'
do
subject
{
trace
.
erase!
}
context
'when it is a live trace'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace_live
)
}
it
{
expect
(
trace
.
raw
).
not_to
be_nil
}
it
"removes trace"
do
subject
expect
(
trace
.
raw
).
to
be_nil
end
end
context
'when it is an archived trace'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace_artifact
)
}
it
"has trace at first"
do
expect
(
trace
.
raw
).
not_to
be_nil
end
it
"removes trace"
do
subject
build
.
reload
expect
(
trace
.
raw
).
to
be_nil
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