summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2019-07-23 15:46:14 -0700
committerGitHub <noreply@github.com>2019-07-23 15:46:14 -0700
commit4076d718c7d5547727527f767bab277cc27110c3 (patch)
treeb09498fc81e95c8c7aa092871aad02c8f4252f52
parent45c89f2ea67b7038ed5a3333de2aebc14e57723f (diff)
parente58646425f4baf0156beb49868b8b15c4fe8f2e7 (diff)
downloadchef-4076d718c7d5547727527f767bab277cc27110c3.tar.gz
Duration field in resource report needs to be String (#8767)
Duration field in resource report needs to be String
-rw-r--r--lib/chef/resource_reporter.rb2
-rw-r--r--spec/unit/resource_reporter_spec.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb
index e63459388d..bbb4fa2e83 100644
--- a/lib/chef/resource_reporter.rb
+++ b/lib/chef/resource_reporter.rb
@@ -35,7 +35,7 @@ class Chef
as_hash["id"] = new_resource.identity.to_s
as_hash["after"] = new_resource.state_for_resource_reporter
as_hash["before"] = current_resource ? current_resource.state_for_resource_reporter : {}
- as_hash["duration"] = ( action_record.elapsed_time * 1000 ).to_i
+ as_hash["duration"] = ( action_record.elapsed_time * 1000 ).to_i.to_s
as_hash["delta"] = new_resource.diff if new_resource.respond_to?("diff")
as_hash["delta"] = "" if as_hash["delta"].nil?
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index a2ae786bb4..1d7fd7fc79 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -447,6 +447,7 @@ describe Chef::ResourceReporter do
# TODO: API takes integer number of milliseconds as a string. This
# should be an int.
expect(@first_update_report).to have_key("duration")
+ expect(@first_update_report["duration"]).to be_kind_of(String)
expect(@first_update_report["duration"].to_i).to be_within(100).of(0)
end
@@ -585,6 +586,7 @@ describe Chef::ResourceReporter do
# TODO: API takes integer number of milliseconds as a string. This
# should be an int.
expect(@first_update_report).to have_key("duration")
+ expect(@first_update_report["duration"]).to be_kind_of(String)
expect(@first_update_report["duration"].to_i).to be_within(100).of(0)
end