diff options
author | Tim Smith <tsmith@chef.io> | 2018-12-14 20:09:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-14 20:09:58 -0800 |
commit | 7acc690d368784df11cb784185a544bf06a2332c (patch) | |
tree | 17a86d750ea809cf40470a8e0ad2919bbebf9698 /spec | |
parent | 86a3c77f8b4be1f4f7eebd621ce7b34c41eb1cd3 (diff) | |
parent | 6247d28ac360873a2346fe852dc7fc442fdc92db (diff) | |
download | chef-7acc690d368784df11cb784185a544bf06a2332c.tar.gz |
Merge pull request #8052 from chef/sp/chef14-backport-8038
Backport: Allow setting the comment on a Windows group
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/group/windows_spec.rb | 15 | ||||
-rw-r--r-- | spec/unit/resource/group_spec.rb | 17 |
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb index 51cd3c58d6..61853c90bd 100644 --- a/spec/unit/provider/group/windows_spec.rb +++ b/spec/unit/provider/group/windows_spec.rb @@ -49,6 +49,7 @@ describe Chef::Provider::Group::Windows do describe "manage_group" do before do @new_resource.members([ "us" ]) + @new_resource.comment = "this is group comment" @current_resource = Chef::Resource::Group.new("staff") @current_resource.members %w{all your base} @new_resource.excluded_members %w{all} @@ -57,6 +58,7 @@ describe Chef::Provider::Group::Windows do allow(@net_group).to receive(:local_add_members) allow(@net_group).to receive(:local_set_members) allow(@provider).to receive(:lookup_account_name) + allow(@net_group).to receive(:local_group_set_info) allow(@provider).to receive(:validate_member!).and_return(true) @provider.current_resource = @current_resource end @@ -73,6 +75,19 @@ describe Chef::Provider::Group::Windows do @provider.manage_group end + it "when comment is present, should call @net_group.local_group_set_info" do + @new_resource.append(true) + expect(@net_group).to receive(:local_group_set_info).with(@new_resource.comment) + @provider.manage_group + end + + it "when comment is not present, should not call @net_group.local_group_set_info" do + @new_resource.comment = nil + @new_resource.append(true) + expect(@net_group).not_to receive(:local_group_set_info).with(@new_resource.comment) + @provider.manage_group + end + it "should call @net_group.local_delete_members" do @new_resource.append(true) allow(@provider).to receive(:lookup_account_name).with("all").and_return("all") diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb index 60f72b6785..6d9df79299 100644 --- a/spec/unit/resource/group_spec.rb +++ b/spec/unit/resource/group_spec.rb @@ -49,6 +49,10 @@ describe Chef::Resource::Group, "initialize" do expect(resource.members).to eql([]) end + it "defaults comment to be nil" do + expect(resource.comment).to eql(nil) + end + it "aliases users to members, also an empty array" do expect(resource.users).to eql([]) end @@ -146,3 +150,16 @@ describe Chef::Resource::Group, "append" do end end end + +describe Chef::Resource::Group, "comment" do + let(:resource) { Chef::Resource::Group.new("fakey_fakerton") } + + it "allows an string" do + resource.comment "this is a group comment" + expect(resource.comment).to eql("this is a group comment") + end + + it "does not allow a hash" do + expect { resource.send(:comment, { some_other_user: "is freakin awesome" }) }.to raise_error(ArgumentError) + end +end |