summaryrefslogtreecommitdiff
path: root/spec/unit/cookbook/metadata_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-05-15 10:54:01 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-05-15 10:54:01 -0700
commit13339a0a0fccd8e3516ef8f4946b90f648a8907a (patch)
treeee1e1d2c70edcbb91729dc01395c024231d0fad6 /spec/unit/cookbook/metadata_spec.rb
parentd3b0f2ce30e4a8cbcbdd0c7128f4ae710a189e83 (diff)
downloadchef-13339a0a0fccd8e3516ef8f4946b90f648a8907a.tar.gz
suppress cookbook self-dependencies and warnlcg/warn-cb-self-dep
cookbooks with self-deps: name 'foo' depends 'foo' are useless and can waste cycles in the depsolver (particularly in the non-solution case), and likely limit the possible choices of depsolvers that we could pick at some point to replace gecode. filtering out the self-dep here will prevent the chef server depsolver from seeing the self-dep and needing to do the work to strip it. also warn the user so that they can remove the self-dep. in the future this will be a hard error. foodcritic also has a rule about removing these.
Diffstat (limited to 'spec/unit/cookbook/metadata_spec.rb')
-rw-r--r--spec/unit/cookbook/metadata_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb
index 760ae5dd2a..d2954726e8 100644
--- a/spec/unit/cookbook/metadata_spec.rb
+++ b/spec/unit/cookbook/metadata_spec.rb
@@ -304,6 +304,21 @@ describe Chef::Cookbook::Metadata do
end
end
end
+
+ it "strips out self-dependencies", :chef_lt_13_only do
+ metadata.name('foo')
+ expect(Chef::Log).to receive(:warn).with(
+ "Ignoring self-dependency in cookbook foo, please remove it (in the future this will be fatal)."
+ )
+ metadata.depends('foo')
+ expect(metadata.dependencies).to eql({})
+ end
+
+ it "errors on self-dependencies", :chef_gte_13_only do
+ metadata.name('foo')
+ expect { metadata.depends('foo') }.to raise_error
+ # FIXME: add the error type
+ end
end
describe "attribute groupings" do