diff --git a/test/helpers/mock_loader.rb b/test/helpers/mock_loader.rb index bc23116cb..15793ba49 100644 --- a/test/helpers/mock_loader.rb +++ b/test/helpers/mock_loader.rb @@ -365,7 +365,7 @@ class MockLoader "netstat -an -f inet" => cmd.call("hpux-netstat-inet"), # ipv6 ports on hpux "netstat -an -f inet6" => cmd.call("hpux-netstat-inet6"), - # hostname linux + # hostname linux and darwin "hostname" => cmd.call("hostname"), # hostname windows "$env:computername" => cmd.call("$env-computername"), @@ -375,6 +375,8 @@ class MockLoader "Get-CimInstance -ClassName Win32_ComputerSystem | Select Manufacturer -ExpandProperty Manufacturer" => cmd.call("manufacturer"), # Model linux "cat /sys/class/dmi/id/product_name" => cmd.call("model"), + # Model darwin + "sysctl -n hw.model" => cmd.call("model_darwin"), # Model windows "Get-CimInstance -ClassName Win32_ComputerSystem | Select Model -ExpandProperty Model" => cmd.call("model"), # windows_hotfix windows diff --git a/test/unit/mock/cmd/model_darwin b/test/unit/mock/cmd/model_darwin new file mode 100644 index 000000000..133066e9d --- /dev/null +++ b/test/unit/mock/cmd/model_darwin @@ -0,0 +1 @@ +MacBookPro13,3 diff --git a/test/unit/resources/sys_info_test.rb b/test/unit/resources/sys_info_test.rb index 98f836e93..db4563669 100644 --- a/test/unit/resources/sys_info_test.rb +++ b/test/unit/resources/sys_info_test.rb @@ -11,6 +11,13 @@ describe "Inspec::Resources::SysInfo" do _(resource.model).must_equal "Flux Capacitor" end + it "check sys_info on OSX" do + resource = MockLoader.new(:osx104).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"