spec/unit/plugins/linux/platform_spec.rb in ohai-8.22.1 vs spec/unit/plugins/linux/platform_spec.rb in ohai-8.23.0

- old
+ new

@@ -15,11 +15,10 @@ # 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") describe Ohai::System, "Linux plugin platform" do let(:have_debian_version) { false } let(:have_redhat_release) { false } @@ -35,10 +34,11 @@ let(:have_oracle_release) { false } let(:have_parallels_release) { false } let(:have_raspi_config) { false } let(:have_os_release) { false } let(:have_cisco_release) { false } + let(:have_cumulus_dir) { false } before(:each) do @plugin = get_plugin("linux/platform") allow(@plugin).to receive(:collect_os).and_return(:linux) @plugin[:lsb] = Mash.new @@ -56,10 +56,11 @@ 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("/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 describe "on lsb compliant distributions" do @@ -169,10 +170,45 @@ @plugin.run expect(@plugin[:platform]).to eq("raspbian") expect(@plugin[:platform_family]).to eq("debian") end end + + context "on cumulus" do + + let(:have_cumulus_dir) { true } + let(:cumulus_release_content) do + <<-OS_RELEASE +NAME="Cumulus Linux" +VERSION_ID=3.1.2 +VERSION="Cumulus Linux 3.1.2" +PRETTY_NAME="Cumulus Linux" +ID=cumulus-linux +ID_LIKE=debian +CPE_NAME=cpe:/o:cumulusnetworks:cumulus_linux:3.1.2 +HOME_URL="http://www.cumulusnetworks.com/" +SUPPORT_URL="http://support.cumulusnetworks.com/" + +OS_RELEASE + end + + before(:each) do + expect(File).to receive(:read).with("/etc/cumulus/etc.replace/os-release").and_return(cumulus_release_content) + end + + # Cumulus is a debian derivative + it "should detect Cumulus as itself with debian as the family" do + @plugin.run + expect(@plugin[:platform]).to eq("cumulus") + expect(@plugin[:platform_family]).to eq("debian") + end + + it "should detect Cumulus platform_version" do + @plugin.run + expect(@plugin[:platform_version]).to eq("3.1.2") + end + end end describe "on slackware" do let(:have_slackware_version) { true } @@ -184,9 +220,15 @@ it "should set platform and platform_family to slackware" do expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0") @plugin.run expect(@plugin[:platform]).to eq("slackware") expect(@plugin[:platform_family]).to eq("slackware") + end + + it "should set platform_version on slackware" do + expect(File).to receive(:read).with("/etc/slackware-version").and_return("Slackware 12.0.0") + @plugin.run + expect(@plugin[:platform_version]).to eq("12.0.0") end end describe "on arch" do