summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-01-14 17:52:59 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-01-20 23:12:48 +0100
commitc45a6bf3ba13cbd532852dfcc48ef3fd7aa545e4 (patch)
tree1482a8d5a7e705bf1d19c37e690ff6b0a13b0fbd /spec/lib
parent714f95b2ff68c02eeee9151c9b456bb2afe7eaff (diff)
downloadgitlab-ce-c45a6bf3ba13cbd532852dfcc48ef3fd7aa545e4.tar.gz
Added cache:key to .gitlab-ci.yml allowing to fine tune the cachingci/cache-key
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb25
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