spec/unit/plugins/linux/platform_spec.rb in ohai-13.1.0 vs spec/unit/plugins/linux/platform_spec.rb in ohai-13.2.0
- old
+ new
@@ -33,10 +33,11 @@
let(:have_enterprise_release) { false }
let(:have_oracle_release) { false }
let(:have_parallels_release) { false }
let(:have_raspi_config) { false }
let(:have_os_release) { false }
+ let(:have_usr_lib_os_release) { false }
let(:have_cisco_release) { false }
let(:have_cumulus_dir) { false }
before(:each) do
@plugin = get_plugin("linux/platform")
@@ -55,10 +56,11 @@
allow(File).to receive(:exist?).with("/etc/enterprise-release").and_return(have_enterprise_release)
allow(File).to receive(:exist?).with("/etc/oracle-release").and_return(have_oracle_release)
allow(File).to receive(:exist?).with("/etc/parallels-release").and_return(have_parallels_release)
allow(File).to receive(:exist?).with("/usr/bin/raspi-config").and_return(have_raspi_config)
allow(File).to receive(:exist?).with("/etc/os-release").and_return(have_os_release)
+ allow(File).to receive(:exist?).with("/usr/lib/os-release").and_return(have_usr_lib_os_release)
allow(File).to receive(:exist?).with("/etc/shared/os-release").and_return(have_cisco_release)
allow(Dir).to receive(:exist?).with("/etc/cumulus").and_return(have_cumulus_dir)
allow(File).to receive(:read).with("PLEASE STUB ALL File.read CALLS")
end
@@ -427,10 +429,18 @@
@plugin.run
expect(@plugin[:platform]).to eq("fedora")
expect(@plugin[:platform_version].to_i).to eq(13)
end
+ it "should read the platform as clearos and version as 7.3" do
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("ClearOS release 7.3.0 (Final)")
+ @plugin.run
+ expect(@plugin[:platform]).to eq("clearos")
+ expect(@plugin[:platform_family]).to eq("rhel")
+ expect(@plugin[:platform_version].to_f).to eq(7.3)
+ end
+
# https://github.com/chef/ohai/issues/560
# Issue is seen on EL7, so that's what we're testing.
context "on versions that have /etc/os-release" do
let(:have_os_release) { true }
@@ -849,8 +859,39 @@
@plugin.run
expect(@plugin[:platform]).to eq("ios_xr")
expect(@plugin[:platform_family]).to eq("wrlinux")
expect(@plugin[:platform_version]).to eq("6.0.0.14I")
+ end
+ end
+
+ describe "on clearlinux" do
+ let(:have_usr_lib_os_release) { true }
+ let(:usr_lib_os_release_content) do
+ <<-CLEARLINUX_RELEASE
+NAME="Clear Linux Software for Intel Architecture"
+VERSION=1
+ID=clear-linux-os
+VERSION_ID=16140
+PRETTY_NAME="Clear Linux OS for Intel Architecture"
+ANSI_COLOR="1;35"
+HOME_URL="https://clearlinux.org"
+SUPPORT_URL="https://clearlinux.org"
+BUG_REPORT_URL="mailto:dev@lists.clearlinux.org"
+PRIVACY_POLICY_URL="http://www.intel.com/privacy"
+CLEARLINUX_RELEASE
+ end
+
+ before do
+ expect(File).to receive(:read).with("/usr/lib/os-release").and_return(usr_lib_os_release_content)
+ end
+
+ it "should set platform to clearlinux and platform_family to clearlinux" do
+ @plugin.lsb = nil
+ @plugin.run
+
+ expect(@plugin[:platform]).to eq("clearlinux")
+ expect(@plugin[:platform_family]).to eq("clearlinux")
+ expect(@plugin[:platform_version]).to eq("16140")
end
end
end