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
d29d2b88
Commit
d29d2b88
authored
Nov 22, 2019
by
Hordur Freyr Yngvason
Committed by
Kamil Trzciński
Nov 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for Auto-DevOps YAML template logic
parent
6c517d23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
0 deletions
+110
-0
spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
...ib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
+110
-0
No files found.
spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
0 → 100644
View file @
d29d2b88
# frozen_string_literal: true
require
'spec_helper'
describe
'Auto-DevOps.gitlab-ci.yml'
do
subject
(
:template
)
{
Gitlab
::
Template
::
GitlabCiYmlTemplate
.
find
(
'Auto-DevOps'
)
}
describe
'the created pipeline'
do
let
(
:user
)
{
create
(
:admin
)
}
let
(
:default_branch
)
{
'master'
}
let
(
:pipeline_branch
)
{
default_branch
}
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'README.md'
=>
''
})
}
let
(
:service
)
{
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
ref:
pipeline_branch
)
}
let
(
:pipeline
)
{
service
.
execute!
(
:push
)
}
let
(
:build_names
)
{
pipeline
.
builds
.
pluck
(
:name
)
}
before
do
stub_ci_pipeline_yaml_file
(
template
.
content
)
allow_any_instance_of
(
Ci
::
BuildScheduleWorker
).
to
receive
(
:perform
).
and_return
(
true
)
allow
(
project
).
to
receive
(
:default_branch
).
and_return
(
default_branch
)
end
it
'creates a build and a test job'
do
expect
(
build_names
).
to
include
(
'build'
,
'test'
)
end
context
'when the project has no active cluster'
do
it
'only creates a build and a test stage'
do
expect
(
pipeline
.
stages_names
).
to
eq
(
%w(build test)
)
end
it
'does not create any deployment-related builds'
do
expect
(
build_names
).
not_to
include
(
'production'
)
expect
(
build_names
).
not_to
include
(
'production_manual'
)
expect
(
build_names
).
not_to
include
(
'staging'
)
expect
(
build_names
).
not_to
include
(
'canary'
)
expect
(
build_names
).
not_to
include
(
'review'
)
expect
(
build_names
).
not_to
include
(
a_string_matching
(
/rollout \d+%/
))
end
end
context
'when the project has an active cluster'
do
let
(
:cluster
)
{
create
(
:cluster
,
:project
,
:provided_by_gcp
,
projects:
[
project
])
}
before
do
allow
(
cluster
).
to
receive
(
:active?
).
and_return
(
true
)
end
describe
'deployment-related builds'
do
context
'on default branch'
do
it
'does not include rollout jobs besides production'
do
expect
(
build_names
).
to
include
(
'production'
)
expect
(
build_names
).
not_to
include
(
'production_manual'
)
expect
(
build_names
).
not_to
include
(
'staging'
)
expect
(
build_names
).
not_to
include
(
'canary'
)
expect
(
build_names
).
not_to
include
(
'review'
)
expect
(
build_names
).
not_to
include
(
a_string_matching
(
/rollout \d+%/
))
end
context
'when STAGING_ENABLED=1'
do
before
do
create
(
:ci_variable
,
project:
project
,
key:
'STAGING_ENABLED'
,
value:
'1'
)
end
it
'includes a staging job and a production_manual job'
do
expect
(
build_names
).
not_to
include
(
'production'
)
expect
(
build_names
).
to
include
(
'production_manual'
)
expect
(
build_names
).
to
include
(
'staging'
)
expect
(
build_names
).
not_to
include
(
'canary'
)
expect
(
build_names
).
not_to
include
(
'review'
)
expect
(
build_names
).
not_to
include
(
a_string_matching
(
/rollout \d+%/
))
end
end
context
'when CANARY_ENABLED=1'
do
before
do
create
(
:ci_variable
,
project:
project
,
key:
'CANARY_ENABLED'
,
value:
'1'
)
end
it
'includes a canary job and a production_manual job'
do
expect
(
build_names
).
not_to
include
(
'production'
)
expect
(
build_names
).
to
include
(
'production_manual'
)
expect
(
build_names
).
not_to
include
(
'staging'
)
expect
(
build_names
).
to
include
(
'canary'
)
expect
(
build_names
).
not_to
include
(
'review'
)
expect
(
build_names
).
not_to
include
(
a_string_matching
(
/rollout \d+%/
))
end
end
end
context
'outside of default branch'
do
let
(
:pipeline_branch
)
{
'patch-1'
}
before
do
project
.
repository
.
create_branch
(
pipeline_branch
)
end
it
'does not include rollout jobs besides review'
do
expect
(
build_names
).
not_to
include
(
'production'
)
expect
(
build_names
).
not_to
include
(
'production_manual'
)
expect
(
build_names
).
not_to
include
(
'staging'
)
expect
(
build_names
).
not_to
include
(
'canary'
)
expect
(
build_names
).
to
include
(
'review'
)
expect
(
build_names
).
not_to
include
(
a_string_matching
(
/rollout \d+%/
))
end
end
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