diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-08-18 17:58:32 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-08-19 17:43:56 +0100 |
commit | 568715fce6d1c022bce065f44a1886f966cc4a95 (patch) | |
tree | ab1c397c7c075b4976b0d4c1eb1b53d6814fd416 /spec/lib | |
parent | aab30f1c979b863cb38ac1140f1f35cb7f0bdafc (diff) | |
download | gitlab-ci-568715fce6d1c022bce065f44a1886f966cc4a95.tar.gz |
Make the YAML validation more stricteryaml-validation
- deny all globals that are not hases and doesn't contain script, the script is required now
- verify that script is either string or array of an strings
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab_ci_yaml_processor_spec.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb index 5b9a4f1..ed3d4e8 100644 --- a/spec/lib/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb @@ -176,7 +176,7 @@ describe GitlabCiYamlProcessor do end it "returns errors if tags parameter is invalid" do - config = YAML.dump({rspec: {tags: "mysql"}}) + config = YAML.dump({rspec: {script: "test", tags: "mysql"}}) expect do GitlabCiYamlProcessor.new(config) end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: tags parameter should be an array of strings") @@ -197,7 +197,7 @@ describe GitlabCiYamlProcessor do end it "returns errors if job image parameter is invalid" do - config = YAML.dump({rspec: {image: ["test"]}}) + config = YAML.dump({rspec: {script: "test", image: ["test"]}}) expect do GitlabCiYamlProcessor.new(config) end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: image should be a string") @@ -218,14 +218,14 @@ describe GitlabCiYamlProcessor do end it "returns errors if job services parameter is not an array" do - config = YAML.dump({rspec: {services: "test"}}) + config = YAML.dump({rspec: {script: "test", 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"]}}) + config = YAML.dump({rspec: {script: "test", services: [10, "test"]}}) expect do GitlabCiYamlProcessor.new(config) end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings") @@ -238,6 +238,13 @@ describe GitlabCiYamlProcessor do end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra") end + it "returns errors if there are unknown parameters that are hashes, but doesn't have a script" do + config = YAML.dump({extra: {services: "test"}}) + expect do + GitlabCiYamlProcessor.new(config) + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra") + end + it "returns errors if there is no any jobs defined" do config = YAML.dump({before_script: ["bundle update"]}) expect do |