summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrabhu Das <prabhu.das@clogeny.com>2013-08-07 15:43:00 +0530
committeradamedx <adamed@opscode.com>2013-08-19 11:52:45 -0700
commit117e00278221a0c2f1c105f8f15113be15bc0559 (patch)
treee90437bb41c74dfe923c3922780cff6b9522327f
parentf608c9c65050e04839d4ee30f9b817c8d1f0e5ee (diff)
downloadohai-117e00278221a0c2f1c105f8f15113be15bc0559.tar.gz
Unit test for Aix plugin uptime.
-rw-r--r--spec/unit/plugins/aix/uptime_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb
new file mode 100644
index 00000000..f7868130
--- /dev/null
+++ b/spec/unit/plugins/aix/uptime_spec.rb
@@ -0,0 +1,44 @@
+#
+# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
+# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
+
+describe Ohai::System, "Aix plugin uptime" do
+
+ uptime_info=<<-WHO
+ . system boot Jul 9 17:51
+ WHO
+
+ before(:each) do
+ @ohai = Ohai::System.new
+ @plugin = Ohai::DSL::Plugin.new(@ohai, File.expand_path("aix/uptime.rb", PLUGIN_PATH))
+ @plugin[:os] = "aix"
+ @uptime_info = uptime_info.split("\n")
+ @plugin.stub(:popen4).with("who -b").and_yield(nil, StringIO.new, @uptime_info, nil)
+ Time.stub_chain(:now, :to_i).and_return(1375857797)
+ end
+
+ it "should set uptime_seconds to uptime" do
+ @plugin.run
+ @plugin[:uptime_seconds].should == 2465537
+ end
+
+ it "should set uptime to a human readable date" do
+ @plugin.run
+ @plugin[:uptime].should == "28 days 12 hours 52 minutes 17 seconds"
+ end
+end