diff options
author | Thom May <thom@may.lt> | 2018-03-21 16:49:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-21 16:49:46 +0000 |
commit | f52b31f01cd4d11e503aa73aa614d5ccbb00b8f7 (patch) | |
tree | cc86e8b9e91a6317084f29af488733a28f373ea8 /spec/unit | |
parent | 26a5e48aa7f447beaee016b0b54ee2076c308dda (diff) | |
parent | 38f11a01425445c161f1dfd2c17ceacbaabf6341 (diff) | |
download | chef-f52b31f01cd4d11e503aa73aa614d5ccbb00b8f7.tar.gz |
Merge pull request #7016 from chef/tm/chef_guid
Save the node's UUID as an attribute
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/client_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/data_collector/messages/helpers_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/node_spec.rb | 8 |
3 files changed, 17 insertions, 1 deletions
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index d92b2e2358..001be10e0b 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -560,7 +560,6 @@ EOM expect { client.node_name }.to raise_error(Chef::Exceptions::CannotDetermineNodeName) end end - end describe "always attempt to run handlers" do diff --git a/spec/unit/data_collector/messages/helpers_spec.rb b/spec/unit/data_collector/messages/helpers_spec.rb index a241bda699..a2c6753003 100644 --- a/spec/unit/data_collector/messages/helpers_spec.rb +++ b/spec/unit/data_collector/messages/helpers_spec.rb @@ -124,8 +124,16 @@ describe Chef::DataCollector::Messages::Helpers do end describe "#node_uuid" do + context "when the node UUID is available in Chef::Config" do + it "returns the configured value" do + Chef::Config[:chef_guid] = "configured_uuid" + expect(TestMessage.node_uuid).to eq("configured_uuid") + end + end + context "when the node UUID can be read" do it "returns the read-in node UUID" do + Chef::Config[:chef_guid] = nil allow(TestMessage).to receive(:read_node_uuid).and_return("read_uuid") expect(TestMessage.node_uuid).to eq("read_uuid") end @@ -133,6 +141,7 @@ describe Chef::DataCollector::Messages::Helpers do context "when the node UUID cannot be read" do it "generated a new node UUID" do + Chef::Config[:chef_guid] = nil allow(TestMessage).to receive(:read_node_uuid).and_return(nil) allow(TestMessage).to receive(:generate_node_uuid).and_return("generated_uuid") expect(TestMessage.node_uuid).to eq("generated_uuid") diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index df85b79fc5..c9f3d7d1d2 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -953,6 +953,14 @@ describe Chef::Node do expect(node.automatic_attrs[:platform_version]).to eq("23.42") end + it "sets the chef guid attribute correctly" do + guid = Chef::Config[:chef_guid] + Chef::Config[:chef_guid] = "test-guid-guid" + node.consume_external_attrs(@ohai_data, {}) + expect(node.automatic_attrs[:chef_guid]).to eq("test-guid-guid") + Chef::Config[:chef_guid] = guid + end + it "consumes the run list from provided json attributes" do node.consume_external_attrs(@ohai_data, { "run_list" => ["recipe[unicorn]"] }) expect(node.run_list).to eq(["recipe[unicorn]"]) |