summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2021-01-12 18:13:29 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2021-01-12 18:28:02 -0800
commitc258deb0d3e0e9a1adcfd3b2c78cafea654c91fb (patch)
treeaf36e1273f9f4b0516e628fcb518623a1ac0da3c
parent5750f3218ccd8bb6750234e7acadcb33a738f7de (diff)
downloadchef-c258deb0d3e0e9a1adcfd3b2c78cafea654c91fb.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>
-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