Skip to content

Commit

Permalink
Add platform_family support for OS X and OS X Server.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaffneyc authored and btm committed Apr 19, 2012
1 parent 39c632e commit 86c79c5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/ohai/plugins/darwin/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.
#

provides "platform", "platform_version", "platform_build"
provides "platform", "platform_version", "platform_build", "platform_family"

popen4("/usr/bin/sw_vers") do |pid, stdin, stdout, stderr|
stdin.close
Expand All @@ -33,4 +33,6 @@
platform_build $1
end
end
end
end

platform_family "mac_os_x"
34 changes: 33 additions & 1 deletion spec/ohai/plugins/darwin/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,36 @@
@ohai._require_plugin("darwin::platform")
@ohai[:platform_build].should == "9F33"
end
end

it "should set platform_family to mac_os_x" do
@ohai._require_plugin("darwin::platform")
@ohai[:platform_family].should == "mac_os_x"
end

describe "on os x server" do
before(:each) do
@ohai = Ohai::System.new
@ohai.stub!(:require_plugin).and_return(true)
@ohai[:os] = "darwin"
@pid = 10
@stdin = mock("STDIN", { :close => true })
@stdout = mock("STDOUT")
@stdout.stub!(:each).
and_yield("ProductName: Mac OS X Server").
and_yield("ProductVersion: 10.6.8").
and_yield("BuildVersion: 10K549")
@stderr = mock("STDERR")
@ohai.stub!(:popen4).with("/usr/bin/sw_vers").and_yield(@pid, @stdin, @stdout, @stderr)
end

it "should set platform to mac_os_x_server" do
@ohai._require_plugin("darwin::platform")
@ohai[:platform].should == "mac_os_x_server"
end

it "should set platform_family to mac_os_x" do
@ohai._require_plugin("darwin::platform")
@ohai[:platform_family].should == "mac_os_x"
end
end
end

0 comments on commit 86c79c5

Please sign in to comment.