diff options
Diffstat (limited to 'spec/lib/ci/gitlab_ci_yaml_processor_spec.rb')
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index d15100fc6d8..f3394910c5b 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -336,7 +336,7 @@ module Ci describe "Caches" do it "returns cache when defined globally" do config = YAML.dump({ - cache: { paths: ["logs/", "binaries/"], untracked: true }, + cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'key' }, rspec: { script: "rspec" } @@ -348,13 +348,14 @@ module Ci expect(config_processor.builds_for_stage_and_ref("test", "master").first[:options][:cache]).to eq( paths: ["logs/", "binaries/"], untracked: true, + key: 'key', ) end it "returns cache when defined in a job" do config = YAML.dump({ rspec: { - cache: { paths: ["logs/", "binaries/"], untracked: true }, + cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'key' }, script: "rspec" } }) @@ -365,15 +366,16 @@ module Ci expect(config_processor.builds_for_stage_and_ref("test", "master").first[:options][:cache]).to eq( paths: ["logs/", "binaries/"], untracked: true, + key: 'key', ) end it "overwrite cache when defined for a job and globally" do config = YAML.dump({ - cache: { paths: ["logs/", "binaries/"], untracked: true }, + cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'global' }, rspec: { script: "rspec", - cache: { paths: ["test/"], untracked: false }, + cache: { paths: ["test/"], untracked: false, key: 'local' }, } }) @@ -383,6 +385,7 @@ module Ci expect(config_processor.builds_for_stage_and_ref("test", "master").first[:options][:cache]).to eq( paths: ["test/"], untracked: false, + key: 'local', ) end end @@ -615,6 +618,20 @@ module Ci end.to raise_error(GitlabCiYamlProcessor::ValidationError, "cache:paths parameter should be an array of strings") end + it "returns errors if cache:key is not a string" do + config = YAML.dump({ cache: { key: 1 }, rspec: { script: "test" } }) + expect do + GitlabCiYamlProcessor.new(config) + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "cache:key parameter should be a string") + end + + it "returns errors if job cache:key is not an a string" do + config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", cache: { key: 1 } } }) + expect do + GitlabCiYamlProcessor.new(config) + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: cache:key parameter should be a string") + end + it "returns errors if job cache:untracked is not an array of strings" do config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", cache: { untracked: "string" } } }) expect do |