From 146a25b1d46da9ed31bff233b00e5e034a91d350 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Wed, 28 Oct 2020 21:14:30 -0700 Subject: Add unit testing for omnios platform detection Make sure this actually works and act as a reference for what the output actually looks like. Signed-off-by: Tim Smith --- spec/unit/plugins/solaris2/platform_spec.rb | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb index 03e34782..0a1aba99 100644 --- a/spec/unit/plugins/solaris2/platform_spec.rb +++ b/spec/unit/plugins/solaris2/platform_spec.rb @@ -105,4 +105,44 @@ describe Ohai::System, "Solaris plugin platform" do end + describe "on OmniOS" do + before do + @uname_x = <<~UNAME_X + System = SunOS + Node = omniosce-vagrant + Release = 5.11 + KernelID = omnios-r151026-673c59f55d + Machine = i86pc + BusType = + Serial = + Users = + OEM# = 0 + Origin# = 1 + NumCPU = 1 + UNAME_X + + allow(File).to receive(:exist?).with("/sbin/uname").and_return(true) + allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, "")) + + @release = StringIO.new(" OmniOS v11 r151026\n Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.\n Copyright 2018 OmniOS Community Edition (OmniOSce) Association.\n All rights reserved. Use is subject to licence terms.") + allow(File).to receive(:open).with("/etc/release").and_yield(@release) + end + + it "runs uname and set platform and build" do + @plugin.run + expect(@plugin[:platform_build]).to eq("omnios-r151026-673c59f55d") + end + + it "sets the platform" do + @plugin.run + expect(@plugin[:platform]).to eq("omnios") + end + + it "sets the platform_version" do + @plugin.run + expect(@plugin[:platform_version]).to eq("151026") + end + + end + end -- cgit v1.2.1