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
Boxiang Sun
gitlab-ce
Commits
bf6126b1
Commit
bf6126b1
authored
Nov 27, 2017
by
Zeger-Jan van de Weg
Committed by
Kamil Trzcinski
Dec 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coverage on legacy artifacts for Ci::Build
parent
e35f1607
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
190 additions
and
77 deletions
+190
-77
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+171
-70
spec/models/project_statistics_spec.rb
spec/models/project_statistics_spec.rb
+19
-7
No files found.
spec/models/ci/build_spec.rb
View file @
bf6126b1
...
...
@@ -132,6 +132,7 @@ describe Ci::Build do
end
describe
'#artifacts?'
do
context
'when new artifacts are used'
do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
subject
{
build
.
artifacts?
}
...
...
@@ -157,6 +158,33 @@ describe Ci::Build do
end
end
context
'when legacy artifacts are used'
do
let
(
:build
)
{
create
(
:ci_build
,
:legacy_artifacts
)
}
subject
{
build
.
artifacts?
}
context
'artifacts archive does not exist'
do
let
(
:build
)
{
create
(
:ci_build
)
}
it
{
is_expected
.
to
be_falsy
}
end
context
'artifacts archive exists'
do
it
{
is_expected
.
to
be_truthy
}
context
'is expired'
do
let!
(
:build
)
{
create
(
:ci_build
,
:legacy_artifacts
,
:expired
)
}
it
{
is_expected
.
to
be_falsy
}
end
context
'is not expired'
do
it
{
is_expected
.
to
be_truthy
}
end
end
end
end
describe
'#artifacts_expired?'
do
subject
{
build
.
artifacts_expired?
}
...
...
@@ -607,11 +635,13 @@ describe Ci::Build do
describe
'#erasable?'
do
subject
{
build
.
erasable?
}
it
{
is_expected
.
to
eq
false
}
end
end
context
'build is erasable'
do
context
'new artifacts'
do
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:artifacts
)
}
describe
'#erase'
do
...
...
@@ -678,6 +708,77 @@ describe Ci::Build do
end
end
context
'old artifacts'
do
context
'build is erasable'
do
context
'new artifacts'
do
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:legacy_artifacts
)
}
describe
'#erase'
do
before
do
build
.
erase
(
erased_by:
user
)
end
context
'erased by user'
do
let!
(
:user
)
{
create
(
:user
,
username:
'eraser'
)
}
include_examples
'erasable'
it
'records user who erased a build'
do
expect
(
build
.
erased_by
).
to
eq
user
end
end
context
'erased by system'
do
let
(
:user
)
{
nil
}
include_examples
'erasable'
it
'does not set user who erased a build'
do
expect
(
build
.
erased_by
).
to
be_nil
end
end
end
describe
'#erasable?'
do
subject
{
build
.
erasable?
}
it
{
is_expected
.
to
be_truthy
}
end
describe
'#erased?'
do
let!
(
:build
)
{
create
(
:ci_build
,
:trace
,
:success
,
:legacy_artifacts
)
}
subject
{
build
.
erased?
}
context
'job has not been erased'
do
it
{
is_expected
.
to
be_falsey
}
end
context
'job has been erased'
do
before
do
build
.
erase
end
it
{
is_expected
.
to
be_truthy
}
end
end
context
'metadata and build trace are not available'
do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:legacy_artifacts
)
}
before
do
build
.
remove_artifacts_metadata!
end
describe
'#erase'
do
it
'does not raise error'
do
expect
{
build
.
erase
}.
not_to
raise_error
end
end
end
end
end
end
end
describe
'#first_pending'
do
let!
(
:first
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
status:
'pending'
,
created_at:
Date
.
yesterday
)
}
let!
(
:second
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
status:
'pending'
)
}
...
...
spec/models/project_statistics_spec.rb
View file @
bf6126b1
...
...
@@ -133,17 +133,29 @@ describe ProjectStatistics do
describe
'#update_build_artifacts_size'
do
let!
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
artifacts_size:
45
.
megabytes
)
}
context
'when new job artifacts are calculated'
do
let
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
create
(
:ci_build
,
pipeline:
pipeline
,
artifacts_size:
56
.
megabytes
)
create
(
:ci_job_artifact
,
:archive
,
project:
pipeline
.
project
,
job:
ci_build
)
end
it
"stores the size of related build artifacts"
do
statistics
.
update_build_artifacts_size
expect
(
statistics
.
build_artifacts_size
).
to
be
(
106365
)
end
end
context
'when legacy artifacts are used'
do
let!
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
artifacts_size:
10
.
megabytes
)
}
it
"stores the size of related build artifacts"
do
expect
(
statistics
.
build_artifacts_size
).
to
eq
(
106012541
)
statistics
.
update_build_artifacts_size
expect
(
statistics
.
build_artifacts_size
).
to
eq
(
10
.
megabytes
)
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