spec/unit/plugins/linux/platform_spec.rb in ohai-7.0.0.rc.0 vs spec/unit/plugins/linux/platform_spec.rb in ohai-7.0.0.rc.1
- old
+ new
@@ -4,23 +4,23 @@
# 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')
-require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
+require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
describe Ohai::System, "Linux plugin platform" do
before(:each) do
@plugin = get_plugin("linux/platform")
@plugin.stub(:collect_os).and_return(:linux)
@@ -40,16 +40,16 @@
describe "on lsb compliant distributions" do
before(:each) do
@plugin[:lsb][:id] = "Ubuntu"
@plugin[:lsb][:release] = "8.04"
end
-
+
it "should set platform to lowercased lsb[:id]" do
- @plugin.run
+ @plugin.run
@plugin[:platform].should == "ubuntu"
end
-
+
it "should set platform_version to lsb[:release]" do
@plugin.run
@plugin[:platform_version].should == "8.04"
end
@@ -142,11 +142,11 @@
@plugin.run
@plugin[:platform].should == "slackware"
@plugin[:platform_family].should == "slackware"
end
end
-
+
describe "on arch" do
before(:each) do
@plugin.lsb = nil
File.should_receive(:exists?).with("/etc/arch-release").and_return(true)
end
@@ -156,11 +156,11 @@
@plugin[:platform].should == "arch"
@plugin[:platform_family].should == "arch"
end
end
-
+
describe "on gentoo" do
before(:each) do
@plugin.lsb = nil
File.should_receive(:exists?).with("/etc/gentoo-release").and_return(true)
end
@@ -217,51 +217,51 @@
@plugin[:lsb][:id] = "Scientific"
@plugin.run
@plugin[:platform_family].should == "rhel"
end
end
-
+
describe "without lsb_release results" do
before(:each) do
@plugin.lsb = nil
File.should_receive(:exists?).with("/etc/redhat-release").and_return(true)
end
-
+
it "should read the platform as centos and version as 5.3" do
File.should_receive(:read).with("/etc/redhat-release").and_return("CentOS release 5.3")
@plugin.run
@plugin[:platform].should == "centos"
end
-
+
it "may be that someone munged Red Hat to be RedHat" do
File.should_receive(:read).with("/etc/redhat-release").and_return("RedHat release 5.3")
@plugin.run
@plugin[:platform].should == "redhat"
@plugin[:platform_version].should == "5.3"
end
-
+
it "should read the platform as redhat and version as 5.3" do
File.should_receive(:read).with("/etc/redhat-release").and_return("Red Hat release 5.3")
@plugin.run
@plugin[:platform].should == "redhat"
@plugin[:platform_version].should == "5.3"
end
-
+
it "should read the platform as fedora and version as 13 (rawhide)" do
File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
@plugin.run
@plugin[:platform].should == "fedora"
@plugin[:platform_version].should == "13 (rawhide)"
end
-
+
it "should read the platform as fedora and version as 10" do
File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 10")
@plugin.run
@plugin[:platform].should == "fedora"
@plugin[:platform_version].should == "10"
end
-
+
it "should read the platform as fedora and version as 13 using to_i" do
File.should_receive(:read).with("/etc/redhat-release").and_return("Fedora release 13 (Rawhide)")
@plugin.run
@plugin[:platform].should == "fedora"
@plugin[:platform_version].to_i.should == 13
@@ -298,11 +298,11 @@
describe "without lsb_results" do
before(:each) do
@plugin.lsb = nil
end
-
+
it "should read the platform as oracle and version as 5" do
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
File.stub(:read).with("/etc/redhat-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
File.should_receive(:exists?).with("/etc/enterprise-release").and_return(true)
File.should_receive(:read).with("/etc/enterprise-release").and_return("Enterprise Linux Enterprise Linux Server release 5 (Carthage)")
@@ -338,11 +338,11 @@
File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.0")
@plugin.run
@plugin[:platform].should == "oracle"
@plugin[:platform_version].should == "6.0"
end
-
+
it "should read the platform as oracle and version as 6.1" do
File.stub(:exists?).with("/etc/redhat-release").and_return(true)
File.stub(:read).with("/etc/redhat-release").and_return("Red Hat Enterprise Linux Server release 6.1 (Santiago)")
File.should_receive(:exists?).with("/etc/oracle-release").and_return(true)
File.should_receive(:read).with("/etc/oracle-release").and_return("Oracle Linux Server release 6.1")
@@ -360,72 +360,77 @@
describe "with lsb_release results" do
before(:each) do
@plugin[:lsb][:id] = "SUSE LINUX"
end
-
- it "should read the platform as suse" do
+
+ it "should read the platform as opensuse on openSUSE" do
@plugin[:lsb][:release] = "12.1"
- File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
+ File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.1 (x86_64)\nVERSION = 12.1\nCODENAME = Asparagus\n")
@plugin.run
- @plugin[:platform].should == "suse"
- @plugin[:platform_version].should == "12.1"
+ @plugin[:platform].should == "opensuse"
@plugin[:platform_family].should == "suse"
end
end
describe "without lsb_release results" do
before(:each) do
@plugin.lsb = nil
end
-
+
it "should set platform and platform_family to suse and bogus verion to 10.0" do
File.should_receive(:read).with("/etc/SuSE-release").at_least(:once).and_return("VERSION = 10.0")
@plugin.run
@plugin[:platform].should == "suse"
@plugin[:platform_family].should == "suse"
end
-
+
it "should read the version as 10.1 for bogus SLES 10" do
File.should_receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 10 (i586)\nVERSION = 10\nPATCHLEVEL = 1\n")
@plugin.run
@plugin[:platform].should == "suse"
@plugin[:platform_version].should == "10.1"
@plugin[:platform_family].should == "suse"
end
-
+
it "should read the version as 11.2" do
File.should_receive(:read).with("/etc/SuSE-release").and_return("SUSE Linux Enterprise Server 11.2 (i586)\nVERSION = 11\nPATCHLEVEL = 2\n")
@plugin.run
@plugin[:platform].should == "suse"
@plugin[:platform_version].should == "11.2"
@plugin[:platform_family].should == "suse"
end
-
+
it "[OHAI-272] should read the version as 11.3" do
File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.3 (x86_64)\nVERSION = 11.3")
@plugin.run
- @plugin[:platform].should == "suse"
+ @plugin[:platform].should == "opensuse"
@plugin[:platform_version].should == "11.3"
@plugin[:platform_family].should == "suse"
end
-
+
it "[OHAI-272] should read the version as 9.1" do
File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("SuSE Linux 9.1 (i586)\nVERSION = 9.1")
@plugin.run
@plugin[:platform].should == "suse"
@plugin[:platform_version].should == "9.1"
@plugin[:platform_family].should == "suse"
end
-
+
it "[OHAI-272] should read the version as 11.4" do
File.should_receive(:read).with("/etc/SuSE-release").exactly(1).times.and_return("openSUSE 11.4 (i586)\nVERSION = 11.4\nCODENAME = Celadon")
@plugin.run
- @plugin[:platform].should == "suse"
+ @plugin[:platform].should == "opensuse"
@plugin[:platform_version].should == "11.4"
@plugin[:platform_family].should == "suse"
end
+
+ it "should read the platform as opensuse on openSUSE" do
+ File.should_receive(:read).with("/etc/SuSE-release").and_return("openSUSE 12.2 (x86_64)\nVERSION = 12.2\nCODENAME = Mantis\n")
+ @plugin.run
+ @plugin[:platform].should == "opensuse"
+ @plugin[:platform_family].should == "suse"
+ end
end
end
end
-