summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2021-01-12 18:13:29 -0800
committerTim Smith <tsmith84@gmail.com>2021-01-19 20:38:23 -0800
commit55142153a9b391173abd6f96a032b9b213d0663f (patch)
treeeb10a2110f55c72aee88bc67a642f5aed6117c0f /spec
parent0ba6d5cba719ebe11e098b3c75dc735cdf19944b (diff)
downloadchef-55142153a9b391173abd6f96a032b9b213d0663f.tar.gz
Fix ohai resource spec
1. this speeds it up by avoiding the sleep and the old ohai data 2. this fixes it because it was totally broken and the old uptime value was nil anyway Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/ohai_spec.rb12
-rw-r--r--spec/spec_helper.rb2
2 files changed, 3 insertions, 11 deletions
diff --git a/spec/functional/resource/ohai_spec.rb b/spec/functional/resource/ohai_spec.rb
index 836a4f6da3..3d6caca088 100644
--- a/spec/functional/resource/ohai_spec.rb
+++ b/spec/functional/resource/ohai_spec.rb
@@ -19,10 +19,6 @@
require "spec_helper"
describe Chef::Resource::Ohai do
- let(:ohai) do
- OHAI_SYSTEM
- end
-
let(:node) { Chef::Node.new }
let(:run_context) do
@@ -34,13 +30,9 @@ describe Chef::Resource::Ohai do
shared_examples_for "reloaded :uptime" do
it "should reload :uptime" do
- initial_uptime = ohai[:uptime]
-
- # Sleep for a second so the uptime gets updated.
- sleep 1
-
+ expect(node[:uptime_seconds]).to be nil
ohai_resource.run_action(:reload)
- expect(node[:uptime]).not_to eq(initial_uptime)
+ expect(Integer(node[:uptime_seconds])).to be_an(Integer)
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 17ce1ab5b7..52f17788bb 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -87,7 +87,7 @@ Dir["spec/support/**/*.rb"]
.each { |f| require f }
OHAI_SYSTEM = Ohai::System.new
-OHAI_SYSTEM.all_plugins(["platform", "hostname", "languages/powershell"])
+OHAI_SYSTEM.all_plugins(["platform", "hostname", "languages/powershell", "uptime"])
test_node = Chef::Node.new
test_node.automatic["os"] = (OHAI_SYSTEM["os"] || "unknown_os").dup.freeze