summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2015-06-19 13:28:37 -0700
committerdanielsdeleo <dan@chef.io>2015-06-19 13:29:42 -0700
commit25023850182bf188da1197e407e99e5e5b87c98a (patch)
tree5740af0a8c14dcb2e141c3a22944fd90855f359f
parent4c389f615afdab97ab8f1718efa5b29c1f3d696c (diff)
downloadohai-25023850182bf188da1197e407e99e5e5b87c98a.tar.gz
Add regression test for EL7 w/o LSB platform detection
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb52
1 files changed, 35 insertions, 17 deletions
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index 41d8261a..a15278ad 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -53,6 +53,8 @@ describe Ohai::System, "Linux plugin platform" do
allow(File).to receive(:exists?).with("/etc/parallels-release").and_return(have_parallels_release)
allow(File).to receive(:exists?).with("/usr/bin/raspi-config").and_return(have_raspi_config)
allow(File).to receive(:exists?).with("/etc/os-release").and_return(have_os_release)
+
+ allow(File).to receive(:read).with("PLEASE STUB ALL File.read CALLS")
end
describe "on lsb compliant distributions" do
@@ -341,27 +343,43 @@ describe Ohai::System, "Linux plugin platform" do
expect(@plugin[:platform_version].to_i).to eq(13)
end
- 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 }
+
+ let(:os_release_content) do
+ <<-OS_RELEASE
+NAME="CentOS Linux"
+VERSION="7 (Core)"
+ID="centos"
+ID_LIKE="rhel fedora"
+VERSION_ID="7"
+PRETTY_NAME="CentOS Linux 7 (Core)"
+ANSI_COLOR="0;31"
+CPE_NAME="cpe:/o:centos:centos:7"
+HOME_URL="https://www.centos.org/"
+BUG_REPORT_URL="https://bugs.centos.org/"
+
+OS_RELEASE
+ end
- ####
- # TODO: This regression test won't work because we stub too much up front.
- # need to refactor the tests first.
- ## # 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
+ before do
+ expect(File).to receive(:read).with("/etc/os-release").and_return(os_release_content)
+ expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS release 7.1")
+ end
+
+ it "correctly detects EL7" do
+ @plugin.run
+ expect(@plugin[:platform]).to eq("centos")
+ expect(@plugin[:platform_version]).to eq("7.1")
+ end
- ## before do
- ## allow(File).to receive(:exists?).with("/etc/os-release").and_return(true)
- ## end
+ end
- ## it "correctly detects EL7" do
- ## expect(File).to receive(:read).with("/etc/redhat-release").and_return("CentOS release 7.1")
- ## @plugin.run
- ## expect(@plugin[:platform]).to eq("centos")
- ## expect(@plugin[:platform_version]).to eq("7.1")
- ## end
+ end
- ## end
end
describe "on pcs linux" do