spec/unit/plugins/linux/platform_spec.rb in ohai-14.8.12 vs spec/unit/plugins/linux/platform_spec.rb in ohai-14.14.0
- old
+ new
@@ -248,11 +248,11 @@
expect(@plugin[:platform]).to eq("arch")
expect(@plugin[:platform_family]).to eq("arch")
end
it "should set platform_version to kernel release" do
- expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.2-2-ARCH")
+ expect(@plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH\n", ""))
@plugin.run
expect(@plugin[:platform_version]).to eq("3.18.2-2-ARCH")
end
end
@@ -269,11 +269,11 @@
expect(@plugin[:platform]).to eq("gentoo")
expect(@plugin[:platform_family]).to eq("gentoo")
end
it "should set platform_version to kernel release" do
- expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.7-gentoo")
+ expect(@plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.7-gentoo\n", ""))
@plugin.run
expect(@plugin[:platform_version]).to eq("3.18.7-gentoo")
end
end
@@ -343,11 +343,11 @@
expect(@plugin[:platform]).to eq("exherbo")
expect(@plugin[:platform_family]).to eq("exherbo")
end
it "should set platform_version to kernel release" do
- expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.2-2-ARCH")
+ expect(@plugin).to receive(:shell_out).with("/bin/uname -r").and_return(mock_shell_out(0, "3.18.2-2-ARCH", ""))
@plugin.run
expect(@plugin[:platform_version]).to eq("3.18.2-2-ARCH")
end
end
@@ -703,10 +703,11 @@
end
describe "on suse" do
context "on openSUSE 15+" do
+ let(:have_usr_lib_os_release) { true }
let(:have_suse_release) { false }
let(:have_os_release) { true }
let(:os_release_content) do
<<~OS_RELEASE
@@ -990,35 +991,71 @@
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
+ context "without /etc/os-release file" do
+ let(:have_os_release) { false }
+ 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)
+ 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
- it "should set platform to clearlinux and platform_family to clearlinux" do
- @plugin.lsb = nil
- @plugin.run
+ context "with /etc/os-release file" do
+ let(:have_os_release) { true }
+ let(:have_usr_lib_os_release) { true }
+ let(: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
- expect(@plugin[:platform]).to eq("clearlinux")
- expect(@plugin[:platform_family]).to eq("clearlinux")
- expect(@plugin[:platform_version]).to eq("16140")
+ before do
+ expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
+ expect(File).not_to receive(:read).with("/usr/lib/os-release")
+ 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
end