summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2014-02-03 15:54:50 -0800
committerdanielsdeleo <dan@opscode.com>2014-02-03 17:00:48 -0800
commit196a36ed5e8d6a2c4ba8703d53ed0f6fd9e5922e (patch)
treef7fedd3b65675a110bf137267850241383cd8476 /spec
parentd472efe27b3c9cd77902002f4158969d5d9eda15 (diff)
downloadchef-196a36ed5e8d6a2c4ba8703d53ed0f6fd9e5922e.tar.gz
[CHEF-3506] suppress final node save when using override run list
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/client_spec.rb4
-rw-r--r--spec/unit/policy_builder/expand_node_object_spec.rb12
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb4
3 files changed, 18 insertions, 2 deletions
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 }