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
713502b0
Commit
713502b0
authored
Mar 23, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix variables expression build policy specs
parent
b6e4e449
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
spec/lib/gitlab/ci/build/policy/variables_spec.rb
spec/lib/gitlab/ci/build/policy/variables_spec.rb
+14
-12
No files found.
spec/lib/gitlab/ci/build/policy/variables_spec.rb
View file @
713502b0
...
@@ -3,54 +3,56 @@ require 'spec_helper'
...
@@ -3,54 +3,56 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Policy
::
Variables
do
describe
Gitlab
::
Ci
::
Build
::
Policy
::
Variables
do
set
(
:project
)
{
create
(
:project
)
}
set
(
:project
)
{
create
(
:project
)
}
let
(
:
ci_
pipeline
)
do
let
(
:pipeline
)
do
build
(
:ci_empty_pipeline
,
project:
project
,
ref:
'master'
)
build
(
:ci_empty_pipeline
,
project:
project
,
ref:
'master'
)
end
end
let
(
:ci_build
)
do
let
(
:ci_build
)
do
build
(
:ci_build
,
pipeline:
ci_
pipeline
,
project:
project
,
ref:
'master'
)
build
(
:ci_build
,
pipeline:
pipeline
,
project:
project
,
ref:
'master'
)
end
end
let
(
:seed
)
{
double
(
'build seed'
,
to_resource:
ci_build
)
}
before
do
before
do
ci_
pipeline
.
variables
.
build
(
key:
'CI_PROJECT_NAME'
,
value:
''
)
pipeline
.
variables
.
build
(
key:
'CI_PROJECT_NAME'
,
value:
''
)
end
end
describe
'#satisfied_by?'
do
describe
'#satisfied_by?'
do
it
'is satisfied by a defined and existing variable'
do
it
'is satisfied by a defined and existing variable'
do
policy
=
described_class
.
new
([
'$CI_PROJECT_ID'
,
'$UNDEFINED'
])
policy
=
described_class
.
new
([
'$CI_PROJECT_ID'
,
'$UNDEFINED'
])
expect
(
policy
).
to
be_satisfied_by
(
ci_pipeline
,
ci_buil
d
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
see
d
)
end
end
it
'is not satisfied by an overriden empty variable'
do
it
'is not satisfied by an overriden empty variable'
do
policy
=
described_class
.
new
([
'$CI_PROJECT_NAME'
])
policy
=
described_class
.
new
([
'$CI_PROJECT_NAME'
])
expect
(
policy
).
not_to
be_satisfied_by
(
ci_pipeline
,
ci_buil
d
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
see
d
)
end
end
it
'is satisfied by a truthy pipeline expression'
do
it
'is satisfied by a truthy pipeline expression'
do
policy
=
described_class
.
new
([
%($CI_PIPELINE_SOURCE == "#{
ci_
pipeline.source}")
])
policy
=
described_class
.
new
([
%($CI_PIPELINE_SOURCE == "#{pipeline.source}")
])
expect
(
policy
).
to
be_satisfied_by
(
ci_pipeline
,
ci_buil
d
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
see
d
)
end
end
it
'is not satisfied by a falsy pipeline expression'
do
it
'is not satisfied by a falsy pipeline expression'
do
policy
=
described_class
.
new
([
%($CI_PIPELINE_SOURCE == "invalid source")
])
policy
=
described_class
.
new
([
%($CI_PIPELINE_SOURCE == "invalid source")
])
expect
(
policy
).
not_to
be_satisfied_by
(
ci_pipeline
,
ci_buil
d
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
see
d
)
end
end
it
'is satisfied by a truthy expression using undefined variable'
do
it
'is satisfied by a truthy expression using undefined variable'
do
policy
=
described_class
.
new
([
'$UNDEFINED'
,
'$UNDEFINED == null'
])
policy
=
described_class
.
new
([
'$UNDEFINED'
,
'$UNDEFINED == null'
])
expect
(
policy
).
to
be_satisfied_by
(
ci_pipeline
,
ci_buil
d
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
see
d
)
end
end
it
'does not persist neither pipeline nor build'
do
it
'does not persist neither pipeline nor build'
do
described_class
.
new
(
'$VAR'
).
satisfied_by?
(
ci_pipeline
,
ci_buil
d
)
described_class
.
new
(
'$VAR'
).
satisfied_by?
(
pipeline
,
see
d
)
expect
(
ci_
pipeline
).
not_to
be_persisted
expect
(
pipeline
).
not_to
be_persisted
expect
(
ci_build
).
not_to
be_persisted
expect
(
seed
.
to_resource
).
not_to
be_persisted
end
end
pending
'test for secret variables'
pending
'test for secret variables'
...
...
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