summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/config
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-03-02 22:12:15 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-03-02 22:12:15 +0800
commit6e032d7ba0cd4ba7053f51dc4e14e0bd69d41217 (patch)
treea380ca012cc2f73841363a6210d1c798ebcd6f1a /spec/lib/gitlab/ci/config
parentbb062ebdb68e5d4d9a92339948ddaaa68cdcf36c (diff)
downloadgitlab-ce-6e032d7ba0cd4ba7053f51dc4e14e0bd69d41217.tar.gz
Set default cache key for jobs, detail:
* Replace Unspecified with a field so that it's less surprising * Define inspect for Node for easy debugging (and avoid building a very huge string potentially from built-in inspect) * Set default cache key to 'default'
Diffstat (limited to 'spec/lib/gitlab/ci/config')
-rw-r--r--spec/lib/gitlab/ci/config/entry/cache_spec.rb15
-rw-r--r--spec/lib/gitlab/ci/config/entry/factory_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/config/entry/global_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/config/entry/job_spec.rb3
-rw-r--r--spec/lib/gitlab/ci/config/entry/jobs_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/config/entry/key_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/config/entry/unspecified_spec.rb32
7 files changed, 30 insertions, 38 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/cache_spec.rb b/spec/lib/gitlab/ci/config/entry/cache_spec.rb
index 70a327c5183..37abbc8a498 100644
--- a/spec/lib/gitlab/ci/config/entry/cache_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/cache_spec.rb
@@ -24,6 +24,21 @@ describe Gitlab::Ci::Config::Entry::Cache do
expect(entry).to be_valid
end
end
+
+ context 'when key is missing' do
+ let(:config) do
+ { untracked: true,
+ paths: ['some/path/'] }
+ end
+
+ describe '#value' do
+ it 'sets key with the default' do
+ value = config.merge(key: Gitlab::Ci::Config::Entry::Key.default)
+
+ expect(entry.value).to eq(value)
+ end
+ end
+ end
end
context 'when entry value is not correct' do
diff --git a/spec/lib/gitlab/ci/config/entry/factory_spec.rb b/spec/lib/gitlab/ci/config/entry/factory_spec.rb
index 3395b3c645b..8dd48e4efae 100644
--- a/spec/lib/gitlab/ci/config/entry/factory_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/factory_spec.rb
@@ -60,13 +60,13 @@ describe Gitlab::Ci::Config::Entry::Factory do
end
context 'when creating entry with nil value' do
- it 'creates an undefined entry' do
+ it 'creates an unspecified entry' do
entry = factory
.value(nil)
.create!
expect(entry)
- .to be_an_instance_of Gitlab::Ci::Config::Entry::Unspecified
+ .not_to be_specified
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/global_spec.rb b/spec/lib/gitlab/ci/config/entry/global_spec.rb
index ebd80ac5e1d..f9f43cae5e0 100644
--- a/spec/lib/gitlab/ci/config/entry/global_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb
@@ -186,7 +186,7 @@ describe Gitlab::Ci::Config::Entry::Global do
it 'contains unspecified nodes' do
expect(global.descendants.first)
- .to be_an_instance_of Gitlab::Ci::Config::Entry::Unspecified
+ .not_to be_specified
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb
index d20f4ec207d..4df119cf00e 100644
--- a/spec/lib/gitlab/ci/config/entry/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb
@@ -144,7 +144,8 @@ describe Gitlab::Ci::Config::Entry::Job do
script: %w[rspec],
commands: "ls\npwd\nrspec",
stage: 'test',
- after_script: %w[cleanup])
+ after_script: %w[cleanup],
+ cache: { key: 'default' })
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb
index aaebf783962..f0d12211483 100644
--- a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb
@@ -62,11 +62,13 @@ describe Gitlab::Ci::Config::Entry::Jobs do
rspec: { name: :rspec,
script: %w[rspec],
commands: 'rspec',
- stage: 'test' },
+ stage: 'test',
+ cache: { key: 'default' } },
spinach: { name: :spinach,
script: %w[spinach],
commands: 'spinach',
- stage: 'test' })
+ stage: 'test',
+ cache: { key: 'default' } })
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/key_spec.rb b/spec/lib/gitlab/ci/config/entry/key_spec.rb
index 0dd36fe1f44..5d4de60bc8a 100644
--- a/spec/lib/gitlab/ci/config/entry/key_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/key_spec.rb
@@ -31,4 +31,10 @@ describe Gitlab::Ci::Config::Entry::Key do
end
end
end
+
+ describe '.default' do
+ it 'returns default key' do
+ expect(described_class.default).to eq 'default'
+ end
+ end
end
diff --git a/spec/lib/gitlab/ci/config/entry/unspecified_spec.rb b/spec/lib/gitlab/ci/config/entry/unspecified_spec.rb
deleted file mode 100644
index 66f88fa35b6..00000000000
--- a/spec/lib/gitlab/ci/config/entry/unspecified_spec.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'spec_helper'
-
-describe Gitlab::Ci::Config::Entry::Unspecified do
- let(:unspecified) { described_class.new(entry) }
- let(:entry) { spy('Entry') }
-
- describe '#valid?' do
- it 'delegates method to entry' do
- expect(unspecified.valid?).to eq entry
- end
- end
-
- describe '#errors' do
- it 'delegates method to entry' do
- expect(unspecified.errors).to eq entry
- end
- end
-
- describe '#value' do
- it 'delegates method to entry' do
- expect(unspecified.value).to eq entry
- end
- end
-
- describe '#specified?' do
- it 'is always false' do
- allow(entry).to receive(:specified?).and_return(true)
-
- expect(unspecified.specified?).to be false
- end
- end
-end