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
c9451120
Commit
c9451120
authored
Oct 02, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Gitaly integration tests for only: changes feature
parent
b772e7f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
46 deletions
+86
-46
spec/lib/gitlab/ci/build/policy/changes_spec.rb
spec/lib/gitlab/ci/build/policy/changes_spec.rb
+77
-45
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+9
-1
No files found.
spec/lib/gitlab/ci/build/policy/changes_spec.rb
View file @
c9451120
...
...
@@ -3,73 +3,105 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Policy
::
Changes
do
set
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
build
(
:ci_empty_pipeline
,
project:
project
,
ref:
'master'
,
source: :push
,
sha:
'1234abcd'
,
before_sha:
'0123aabb'
)
end
describe
'#satisfied_by?'
do
describe
'paths matching matching'
do
let
(
:pipeline
)
do
build
(
:ci_empty_pipeline
,
project:
project
,
ref:
'master'
,
source: :push
,
sha:
'1234abcd'
,
before_sha:
'0123aabb'
)
end
let
(
:ci_build
)
do
build
(
:ci_build
,
pipeline:
pipeline
,
project:
project
,
ref:
'master'
)
end
let
(
:ci_build
)
do
build
(
:ci_build
,
pipeline:
pipeline
,
project:
project
,
ref:
'master'
)
end
let
(
:seed
)
{
double
(
'build seed'
,
to_resource:
ci_build
)
}
let
(
:seed
)
{
double
(
'build seed'
,
to_resource:
ci_build
)
}
before
do
allow
(
pipeline
).
to
receive
(
:modified_paths
)
do
%w[some/modified/ruby/file.rb some/other_file.txt some/.dir/file]
end
end
before
do
allow
(
pipeline
).
to
receive
(
:modified_paths
)
do
%w[some/modified/ruby/file.rb some/other_file.txt some/.dir/file]
end
end
describe
'#satisfied_by?'
do
it
'is satisfied by matching literal path'
do
policy
=
described_class
.
new
(
%w[some/other_file.txt]
)
it
'is satisfied by matching literal path'
do
policy
=
described_class
.
new
(
%w[some/other_file.txt]
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is satisfied by matching simple pattern'
do
policy
=
described_class
.
new
(
%w[some/*.txt]
)
it
'is satisfied by matching simple pattern'
do
policy
=
described_class
.
new
(
%w[some/*.txt]
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is satisfied by matching recusive pattern'
do
policy
=
described_class
.
new
(
%w[some/**/*.rb]
)
it
'is satisfied by matching recusive pattern'
do
policy
=
described_class
.
new
(
%w[some/**/*.rb]
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is satisfied by matching a pattern with a dot'
do
policy
=
described_class
.
new
(
%w[some/*/file]
)
it
'is satisfied by matching a pattern with a dot'
do
policy
=
described_class
.
new
(
%w[some/*/file]
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is not satisfied when pattern does not match path'
do
policy
=
described_class
.
new
(
%w[some/*.rb]
)
it
'is not satisfied when pattern does not match path'
do
policy
=
described_class
.
new
(
%w[some/*.rb]
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
seed
)
end
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is not satisfied when pattern does not match'
do
policy
=
described_class
.
new
(
%w[invalid/*.md]
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
seed
)
end
context
'when pipelines does not run for a branch update'
do
before
do
pipeline
.
before_sha
=
Gitlab
::
Git
::
BLANK_SHA
end
it
'is not satisfied when pattern does not match
'
do
policy
=
described_class
.
new
(
%w[invalid/*.md
]
)
it
'is always satisfied
'
do
policy
=
described_class
.
new
(
%w[invalid/*
]
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
seed
)
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
end
end
context
'when pipelines does not run for a branch update'
do
before
do
pipeline
.
before_sha
=
Gitlab
::
Git
::
BLANK_SHA
describe
'gitaly integration'
do
set
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
project:
project
,
ref:
'master'
,
source: :push
,
sha:
'498214d'
,
before_sha:
'281d3a7'
)
end
let
(
:build
)
do
create
(
:ci_build
,
pipeline:
pipeline
,
project:
project
,
ref:
'master'
)
end
it
'is always satisfied'
do
policy
=
described_class
.
new
(
%w[invalid/*]
)
let
(
:seed
)
{
double
(
'build seed'
,
to_resource:
build
)
}
it
'is satisfied by changes introduced by a push'
do
policy
=
described_class
.
new
([
'with space/*.md'
])
expect
(
policy
).
to
be_satisfied_by
(
pipeline
,
seed
)
end
it
'is not satisfied by changes that are not in the push'
do
policy
=
described_class
.
new
(
%w[files/js/commit.js]
)
expect
(
policy
).
not_to
be_satisfied_by
(
pipeline
,
seed
)
end
end
end
end
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
c9451120
...
...
@@ -1354,7 +1354,7 @@ module Gitlab
end
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"jobs:rspec dependencies should be an array of strings"
)
end
it
'returns errors if pipeline variables expression is invalid'
do
it
'returns errors if pipeline variables expression
policy
is invalid'
do
config
=
YAML
.
dump
({
rspec:
{
script:
'test'
,
only:
{
variables:
[
'== null'
]
}
}
})
expect
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
...
...
@@ -1362,6 +1362,14 @@ module Gitlab
'jobs:rspec:only variables invalid expression syntax'
)
end
it
'returns errors if pipeline changes policy is invalid'
do
config
=
YAML
.
dump
({
rspec:
{
script:
'test'
,
only:
{
changes:
[
1
]
}
}
})
expect
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
'jobs:rspec:only changes should be an array of strings'
)
end
it
'returns errors if extended hash configuration is invalid'
do
config
=
YAML
.
dump
({
rspec:
{
extends:
'something'
,
script:
'test'
}
})
...
...
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