summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-10-28 21:14:30 -0700
committerTim Smith <tsmith84@gmail.com>2020-10-28 21:14:30 -0700
commit146a25b1d46da9ed31bff233b00e5e034a91d350 (patch)
treecbb868ddb656fd8e3aafc76386a70533c6c75f76
parente6258ed31f526bc268cef47280b12d4c227973bf (diff)
downloadohai-146a25b1d46da9ed31bff233b00e5e034a91d350.tar.gz
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 <tsmith@chef.io>
-rw-r--r--spec/unit/plugins/solaris2/platform_spec.rb40
1 files changed, 40 insertions, 0 deletions
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 = <unknown>
+ Serial = <unknown>
+ Users = <unknown>
+ 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