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
3a1103fd
Commit
3a1103fd
authored
Aug 17, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for stage status background migration class
parent
d1cfa79d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb
.../gitlab/background_migration/migrate_stage_status_spec.rb
+80
-0
No files found.
spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb
0 → 100644
View file @
3a1103fd
require
'spec_helper'
describe
Gitlab
::
BackgroundMigration
::
MigrateStageStatus
,
:migration
,
schema:
20170711145320
do
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:pipelines
)
{
table
(
:ci_pipelines
)
}
let
(
:stages
)
{
table
(
:ci_stages
)
}
let
(
:jobs
)
{
table
(
:ci_builds
)
}
STATUSES
=
{
created:
0
,
pending:
1
,
running:
2
,
success:
3
,
failed:
4
,
canceled:
5
,
skipped:
6
,
manual:
7
}.
freeze
before
do
projects
.
create!
(
id:
1
,
name:
'gitlab1'
,
path:
'gitlab1'
)
pipelines
.
create!
(
id:
1
,
project_id:
1
,
ref:
'master'
,
sha:
'adf43c3a'
)
stages
.
create!
(
id:
1
,
pipeline_id:
1
,
project_id:
1
,
name:
'test'
,
status:
nil
)
stages
.
create!
(
id:
2
,
pipeline_id:
1
,
project_id:
1
,
name:
'deploy'
,
status:
nil
)
end
context
'when stage status is known'
do
before
do
create_job
(
project:
1
,
pipeline:
1
,
stage:
'test'
,
status:
'success'
)
create_job
(
project:
1
,
pipeline:
1
,
stage:
'test'
,
status:
'running'
)
create_job
(
project:
1
,
pipeline:
1
,
stage:
'deploy'
,
status:
'failed'
)
end
it
'sets a correct stage status'
do
described_class
.
new
.
perform
(
1
,
2
)
expect
(
stages
.
first
.
status
).
to
eq
STATUSES
[
:running
]
expect
(
stages
.
second
.
status
).
to
eq
STATUSES
[
:failed
]
end
end
context
'when stage status is not known'
do
it
'sets a skipped stage status'
do
described_class
.
new
.
perform
(
1
,
2
)
expect
(
stages
.
first
.
status
).
to
eq
STATUSES
[
:skipped
]
expect
(
stages
.
second
.
status
).
to
eq
STATUSES
[
:skipped
]
end
end
context
'when stage status includes status of a retried job'
do
before
do
create_job
(
project:
1
,
pipeline:
1
,
stage:
'test'
,
status:
'canceled'
)
create_job
(
project:
1
,
pipeline:
1
,
stage:
'deploy'
,
status:
'failed'
,
retried:
true
)
create_job
(
project:
1
,
pipeline:
1
,
stage:
'deploy'
,
status:
'success'
)
end
it
'sets a correct stage status'
do
described_class
.
new
.
perform
(
1
,
2
)
expect
(
stages
.
first
.
status
).
to
eq
STATUSES
[
:canceled
]
expect
(
stages
.
second
.
status
).
to
eq
STATUSES
[
:success
]
end
end
context
'when some job in the stage is blocked / manual'
do
before
do
create_job
(
project:
1
,
pipeline:
1
,
stage:
'test'
,
status:
'failed'
)
create_job
(
project:
1
,
pipeline:
1
,
stage:
'test'
,
status:
'manual'
)
create_job
(
project:
1
,
pipeline:
1
,
stage:
'deploy'
,
status:
'success'
,
when:
'manual'
)
end
it
'sets a correct stage status'
do
described_class
.
new
.
perform
(
1
,
2
)
expect
(
stages
.
first
.
status
).
to
eq
STATUSES
[
:manual
]
expect
(
stages
.
second
.
status
).
to
eq
STATUSES
[
:success
]
end
end
def
create_job
(
project
:,
pipeline
:,
stage
:,
status
:,
**
opts
)
stages
=
{
test:
1
,
build:
2
,
deploy:
3
}
jobs
.
create!
(
project_id:
project
,
commit_id:
pipeline
,
stage_idx:
stages
[
stage
.
to_sym
],
stage:
stage
,
status:
status
,
**
opts
)
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