summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-06-30 12:57:26 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-06 13:04:36 +0200
commit073c2a556e145d511e976b92f364b03aa4f3dd7f (patch)
treeef1d641b1eeec565cf2fd3a923fe95f97fb4c6be /spec/lib
parentb27f990de8a1b53974eb9aa0bd6bdde18f93d6db (diff)
downloadgitlab-ci-073c2a556e145d511e976b92f364b03aa4f3dd7f.tar.gz
Added support for image and services
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab_ci_yaml_processor_spec.rb98
1 files changed, 96 insertions, 2 deletions
diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb
index 465ee9e..9c9fde9 100644
--- a/spec/lib/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb
@@ -17,7 +17,8 @@ describe GitlabCiYamlProcessor do
name: :rspec,
only: nil,
script: "pwd\nrspec",
- tags: []
+ tags: [],
+ options: {}
}
end
@@ -81,7 +82,8 @@ describe GitlabCiYamlProcessor do
name: :rspec,
only: nil,
script: "pwd\nrspec",
- tags: []
+ tags: [],
+ options: {}
}
end
@@ -130,6 +132,56 @@ describe GitlabCiYamlProcessor do
end
end
+ describe "Image and service handling" do
+ it "returns image and service when defined" do
+ config = YAML.dump({
+ image: "ruby:2.1",
+ services: ["mysql"],
+ before_script: ["pwd"],
+ rspec: {script: "rspec"}
+ })
+
+ config_processor = GitlabCiYamlProcessor.new(config)
+
+ config_processor.builds_for_ref("master").size.should == 1
+ config_processor.builds_for_ref("master").first.should == {
+ except: nil,
+ name: :rspec,
+ only: nil,
+ script: "pwd\nrspec",
+ tags: [],
+ options: {
+ image: "ruby:2.1",
+ services: ["mysql"]
+ }
+ }
+ end
+
+ it "returns image and service when overridden for job" do
+ config = YAML.dump({
+ image: "ruby:2.1",
+ services: ["mysql"],
+ before_script: ["pwd"],
+ rspec: {image: "ruby:2.5", services: ["postgresql"], script: "rspec"}
+ })
+
+ config_processor = GitlabCiYamlProcessor.new(config)
+
+ config_processor.builds_for_ref("master").size.should == 1
+ config_processor.builds_for_ref("master").first.should == {
+ except: nil,
+ name: :rspec,
+ only: nil,
+ script: "pwd\nrspec",
+ tags: [],
+ options: {
+ image: "ruby:2.5",
+ services: ["postgresql"]
+ }
+ }
+ end
+ end
+
describe "Error handling" do
it "indicates that object is invalid" do
expect{GitlabCiYamlProcessor.new("invalid_yaml\n!ccdvlf%612334@@@@")}.to raise_error(GitlabCiYamlProcessor::ValidationError)
@@ -149,6 +201,48 @@ describe GitlabCiYamlProcessor do
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "before_script should be an array")
end
+ it "returns errors if image parameter is invalid" do
+ config = YAML.dump({image: ["test"], rspec: {script: "test"}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "image should be a string")
+ end
+
+ it "returns errors if job image parameter is invalid" do
+ config = YAML.dump({rspec: {image: ["test"]}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: image should be a string")
+ end
+
+ it "returns errors if services parameter is not an array" do
+ config = YAML.dump({services: "test", rspec: {script: "test"}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "services should be an array of strings")
+ end
+
+ it "returns errors if services parameter is not an array of strings" do
+ config = YAML.dump({services: [10, "test"], rspec: {script: "test"}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "services should be an array of strings")
+ end
+
+ it "returns errors if job services parameter is not an array" do
+ config = YAML.dump({rspec: {services: "test"}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
+ end
+
+ it "returns errors if job services parameter is not an array of strings" do
+ config = YAML.dump({rspec: {services: [10, "test"]}})
+ expect do
+ GitlabCiYamlProcessor.new(config)
+ end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
+ end
+
it "returns errors if there are unknown parameters" do
config = YAML.dump({extra: "bundle update"})
expect do