diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2018-06-14 18:52:58 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2018-06-14 18:52:58 -0700 |
commit | e771309797f70ac5c37ba70c739db47902056513 (patch) | |
tree | c1584d2ca903a241a9cfc0d110134d3cf4e2861c /spec/unit | |
parent | 9305d75f4c17aa09ddf7388c0ba53d1c57490258 (diff) | |
download | chef-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>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/deprecated_spec.rb | 11 |
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 |