inspec/test/unit/resources/sys_info_test.rb
Bryan McLellan dada8ea074 Add the generic 'darwin' to the service resource
macOS 11 Big Sur will be released later this year. Current beta versions
return 10.16 as the version, but the product name has changed from 'Mac
OS X' to 'macOS'. Train probably needs to be modified to deprecate
'mac_os_x' as a platform in favor of 'macos' but that would be a
significant downstream change. Train does fall back to 'darwin' on macOS
10.16, so by adding darwin to the list of platform names for the service
resource we are able to work around this for the moment.

This is the only location where mac_os_x is currently being used in
InSpec. Because we're in a case statement on platform rather than the
more generic platform family, we can't simply remove mac_os_x in favor
of darwin.

Signed-off-by: Bryan McLellan <btm@loftninjas.org>
2020-07-02 09:36:27 -04:00

35 lines
1.4 KiB
Ruby

require "helper"
require "inspec/resource"
require "inspec/resources/sys_info"
describe "Inspec::Resources::SysInfo" do
describe "sys_info" do
it "check sys_info on Ubuntu" do
resource = MockLoader.new(:ubuntu1504).load_resource("sys_info")
_(resource.hostname).must_equal "example.com"
_(resource.manufacturer).must_equal "ACME Corp."
_(resource.model).must_equal "Flux Capacitor"
end
it "check sys_info on OSX" do
resource = MockLoader.new(:macos10_10).load_resource("sys_info")
_(resource.hostname).must_equal "example.com"
_(resource.manufacturer).must_equal "Apple Inc."
_(resource.model).must_equal "MacBookPro13,3"
end
it "check sys_info on Windows" do
resource = MockLoader.new(:windows).load_resource("sys_info")
_(resource.hostname).must_equal "WIN-CIV7VMLVHLD"
_(resource.manufacturer).must_equal "ACME Corp."
_(resource.model).must_equal "Flux Capacitor"
end
it "check sysinfo on freebsd" do
resource = MockLoader.new(:freebsd10).load_resource("sys_info")
_(resource.hostname).must_equal "The `sys_info.hostname` resource is not supported on your OS yet."
_(resource.manufacturer).must_equal "The `sys_info.manufacturer` resource is not supported on your OS yet."
_(resource.model).must_equal "The `sys_info.model` resource is not supported on your OS yet."
end
end
end