summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2021-06-01 12:40:25 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2021-06-01 12:40:25 -0700
commit954c7a7feabf0bead4f4c187ab364d51fb737e2b (patch)
tree980f90af3b5345798a14689131f5b75f94a613e5 /spec
parent16790dd482774de1f9b7c46ef381b0b7bfac5bf8 (diff)
downloadchef-954c7a7feabf0bead4f4c187ab364d51fb737e2b.tar.gz
Fix Chef::Handler specs and slow report behavior
The slow report now walks through action records instead of the resources and should have unique records for elapsed_time and will report the slowest actions. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/handler_spec.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/unit/handler_spec.rb b/spec/unit/handler_spec.rb
index a9820e8a70..ee30113d1c 100644
--- a/spec/unit/handler_spec.rb
+++ b/spec/unit/handler_spec.rb
@@ -38,6 +38,8 @@ describe Chef::Handler do
@run_context = Chef::RunContext.new(@node, {}, @events)
@all_resources = [Chef::Resource::Cat.new("lolz"), Chef::Resource::ZenMaster.new("tzu")]
@all_resources.first.updated_by_last_action true
+ @handler.instance_variable_set(:@all_resources, @all_resources)
+ @handler.instance_variable_set(:@updated_resources, [@all_resources.first])
@run_context.resource_collection.all_resources.replace(@all_resources)
@run_status.run_context = @run_context
@start_time = Time.now
@@ -119,6 +121,8 @@ describe Chef::Handler do
@run_context = Chef::RunContext.new(@node, {}, @events)
@all_resources = [Chef::Resource::Cat.new("foo"), Chef::Resource::ZenMaster.new("moo")]
@all_resources.first.updated_by_last_action true
+ @handler.instance_variable_set(:@all_resources, @all_resources)
+ @handler.instance_variable_set(:@updated_resources, [@all_resources.first])
@run_context.resource_collection.all_resources.replace(@all_resources)
@run_status.run_context = @run_context
@start_time = Time.now
@@ -169,17 +173,19 @@ describe Chef::Handler do
# and this would test the start handler
describe "when running a start handler" do
before do
+ @handler.instance_variable_set(:@all_resources, [])
+ @handler.instance_variable_set(:@updated_resources, [])
@start_time = Time.now
allow(Time).to receive(:now).and_return(@start_time)
@run_status.start_clock
end
it "should not have all resources" do
- expect(@handler.all_resources).to be_falsey
+ expect(@handler.all_resources).to be_empty
end
it "should not have updated resources" do
- expect(@handler.updated_resources).to be_falsey
+ expect(@handler.updated_resources).to be_empty
end
it "has a shortcut for the start time" do