summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2018-06-14 18:52:58 -0700
committerNoah Kantrowitz <noah@coderanger.net>2018-06-14 18:52:58 -0700
commite771309797f70ac5c37ba70c739db47902056513 (patch)
treec1584d2ca903a241a9cfc0d110134d3cf4e2861c
parent9305d75f4c17aa09ddf7388c0ba53d1c57490258 (diff)
downloadchef-e771309797f70ac5c37ba70c739db47902056513.tar.gz
Add a test to check for colliding deprecation IDs in case we forget some day.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r--spec/unit/deprecated_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/unit/deprecated_spec.rb b/spec/unit/deprecated_spec.rb
index 6b52c30032..fa4e70299b 100644
--- a/spec/unit/deprecated_spec.rb
+++ b/spec/unit/deprecated_spec.rb
@@ -51,4 +51,15 @@ describe Chef::Deprecated do
expect(TestDeprecation.new(message, location).to_s).to eql("A test message (CHEF-999)the location.\nPlease see https://docs.chef.io/deprecations_test.html for further details and information on how to correct this problem.")
end
end
+
+ it "has no overlapping deprecation IDs" do
+ id_map = {}
+ ObjectSpace.each_object(Class).select { |cls| cls < Chef::Deprecated::Base }.each do |cls|
+ (id_map[cls.deprecation_id] ||= []) << cls
+ end
+ collisions = id_map.select {|k, v| v.size != 1 }
+ unless collisions.empty?
+ raise "Found deprecation ID collisions:\n#{collisions.map {|k, v| "* #{k} #{v.map(&:name).join(', ')}"}.join("\n")}"
+ end
+ end
end