From 5c7e4ba0308f33fc28dd693f23403673f10a527a Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Thu, 16 Apr 2020 22:43:25 -0700 Subject: Add unit tests around Chef::VersionString I guess this is minimum viable testing to ensure this doesn't break in the future. Signed-off-by: Lamont Granquist --- spec/unit/node_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index e6d351bc0d..f2a5528b52 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -940,6 +940,23 @@ describe Chef::Node do expect(node["one"].to_hash).to eq({ "two" => { "three" => "forty-two" } }) end + it "converts the platform_version to a Chef::VersionString" do + node.consume_external_attrs(@ohai_data, {}) + expect(node["platform_version"]).to be_kind_of(Chef::VersionString) + end + end + + describe "merging ohai data" do + before do + @ohai_data = { platform: "foo", platform_version: "bar" } + end + + it "converts the platform_version to a Chef::VersionString" do + node.consume_external_attrs(@ohai_data, {}) + node.consume_ohai_data({ "platform_version" => "6.3" }) + expect(node["platform_version"]).to be_kind_of(Chef::VersionString) + expect(node["platform_version"] =~ "~> 6.1").to be true + end end describe "preparing for a chef client run" do -- cgit v1.2.1