From 196a36ed5e8d6a2c4ba8703d53ed0f6fd9e5922e Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Mon, 3 Feb 2014 15:54:50 -0800 Subject: [CHEF-3506] suppress final node save when using override run list --- spec/unit/client_spec.rb | 4 ++-- spec/unit/policy_builder/expand_node_object_spec.rb | 12 ++++++++++++ spec/unit/policy_builder/policyfile_spec.rb | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 6dc10c21b8..58a643d403 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -422,7 +422,7 @@ shared_examples_for Chef::Client do @client = Chef::Client.new(nil, :override_runlist => 'role[a], role[b]') end - it "should override the run list and save original runlist" do + it "should override the run list and skip the final node save" do @client = Chef::Client.new(nil, :override_runlist => 'role[test_role]') @client.node = @node @@ -438,7 +438,7 @@ shared_examples_for Chef::Client do mock_chef_rest.should_receive(:get_rest).with("roles/test_role").and_return(override_role) Chef::REST.should_receive(:new).and_return(mock_chef_rest) - @node.should_receive(:save).and_return(nil) + @node.should_not_receive(:save) @client.policy_builder.stub(:node).and_return(@node) @client.policy_builder.build_node diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb index dc8b532e2b..5c6f39d28c 100644 --- a/spec/unit/policy_builder/expand_node_object_spec.rb +++ b/spec/unit/policy_builder/expand_node_object_spec.rb @@ -59,6 +59,10 @@ describe Chef::PolicyBuilder::ExpandNodeObject do expect(policy_builder).to respond_to(:sync_cookbooks) end + it "implements a temporary_policy? method" do + expect(policy_builder).to respond_to(:temporary_policy?) + end + describe "loading the node" do context "on chef-solo" do @@ -181,6 +185,10 @@ describe Chef::PolicyBuilder::ExpandNodeObject do expect(node["fqdn"]).to eq(ohai_data["fqdn"]) end + it "reports that a temporary_policy is not being used" do + expect(policy_builder.temporary_policy?).to be_false + end + describe "when the given run list is not in expanded form" do # NOTE: for chef-client, the behavior is always to expand the run list, @@ -239,6 +247,10 @@ describe Chef::PolicyBuilder::ExpandNodeObject do expect(policy_builder.original_runlist).to eq(primary_runlist) end + it "reports that a temporary policy is being used" do + expect(policy_builder.temporary_policy?).to be_true + end + end context "when no environment is specified" do diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb index aeda1af773..f02c79ef12 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -106,6 +106,10 @@ describe Chef::PolicyBuilder::Policyfile do Chef::PolicyBuilder::Policyfile.new(node_name, ohai_data, json_attribs, override_runlist, events) end + it "always gives `false` for #temporary_policy?" do + expect(initialize_pb.temporary_policy?).to be_false + end + context "chef-solo" do before { Chef::Config[:solo] = true } -- cgit v1.2.1