Fix for default null values compatible for both windows and non-windows system

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
Nikita Mathur 2021-04-22 18:46:02 +05:30
parent 457e544724
commit 7693363a1a
2 changed files with 6 additions and 2 deletions

View file

@ -118,7 +118,7 @@ module Inspec::Resources
end
def members
flatten_entry(group_info, "members") || []
flatten_entry(group_info, "members") || empty_value_for_members
end
def members_array
@ -152,6 +152,10 @@ module Inspec::Resources
group = @group.dup
@groups_cache ||= inspec.groups.where { name == group }
end
def empty_value_for_members
inspec.os.windows? ? [] : ""
end
end
class GroupInfo

View file

@ -108,6 +108,6 @@ describe "Inspec::Resources::Group" do
it "verify non-existent group member on centos" do
resource = MockLoader.new(:centos7).load_resource("group", "root")
_(resource.exists?).must_equal true
_(resource.members).must_equal []
_(resource.members).must_equal ""
end
end