summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-04-02 19:52:21 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-04-02 19:52:21 -0700
commit8dcf5be92642700ee3f2aedb83484bcf0e2c159c (patch)
tree3f44abd8bef8e75f05f57cd1213f14418aabed7a /spec
parent333e0695117f8a518b8f2729bc3f97a5bd6560e4 (diff)
downloadchef-8dcf5be92642700ee3f2aedb83484bcf0e2c159c.tar.gz
Change name_property to be identity and not desired_state by default
If no other property is an identity property then the name_property is the default identity property. The name_property is also marked as not being desired state by default (the 'name' should never change). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/property/state_spec.rb19
-rw-r--r--spec/unit/resource_reporter_spec.rb8
2 files changed, 14 insertions, 13 deletions
diff --git a/spec/unit/property/state_spec.rb b/spec/unit/property/state_spec.rb
index a6428e8617..f120039f8b 100644
--- a/spec/unit/property/state_spec.rb
+++ b/spec/unit/property/state_spec.rb
@@ -285,8 +285,8 @@ describe "Chef::Resource#identity and #state" do
it "identity when x is not defined returns the value of x" do
expect(resource.identity).to eq "blah"
end
- it "state when x is not defined returns the value of x" do
- expect(resource.state_for_resource_reporter).to eq(x: "blah")
+ it "the name property is not included in the desired state" do
+ expect(resource.state_for_resource_reporter).to eq({})
end
end
end
@@ -332,12 +332,17 @@ describe "Chef::Resource#identity and #state" do
end
with_property ":x, name_property: true" do
- # it "Unset values with name_property are included in state" do
- # expect(resource.state_for_resource_reporter).to eq({ x: 'blah' })
- # end
- it "Set values with name_property are included in state" do
+ it "Is by default the identity property if no other identity property is included" do
+ expect(resource.identity).to eq("blah")
+ end
+
+ it "Unset values with name_property are not included in state" do
+ expect(resource.state_for_resource_reporter).to eq({})
+ end
+
+ it "Set values with name_property are not included in state" do
resource.x 1
- expect(resource.state_for_resource_reporter).to eq(x: 1)
+ expect(resource.state_for_resource_reporter).to eq({})
end
end
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index 775b14ef19..22bba578eb 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -3,7 +3,7 @@
# Author:: Prajakta Purohit (<prajakta@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
#
-# Copyright:: Copyright 2012-2019, Chef Software Inc.
+# Copyright:: Copyright 2012-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -294,7 +294,7 @@ describe Chef::ResourceReporter do
resource_reporter.run_started(run_status)
end
- context "when the new_resource is sensitive" do
+ context "when the new_resource is a sensitive execute resource" do
before do
@execute_resource = Chef::Resource::Execute.new("sensitive-resource")
@execute_resource.name("sensitive-resource")
@@ -312,10 +312,6 @@ describe Chef::ResourceReporter do
it "resource_name in prepared_run_data should be the same" do
expect(@first_update_report["name"]).to eq("sensitive-resource")
end
-
- it "resource_command in prepared_run_data should be blank" do
- expect(@first_update_report["after"]).to eq({ command: "sensitive-resource" })
- end
end
context "when the new_resource does not have a string for name and identity" do