diff options
Diffstat (limited to 'spec/functional')
-rw-r--r-- | spec/functional/mixin/powershell_out_spec.rb | 8 | ||||
-rw-r--r-- | spec/functional/resource/group_spec.rb | 33 |
2 files changed, 23 insertions, 18 deletions
diff --git a/spec/functional/mixin/powershell_out_spec.rb b/spec/functional/mixin/powershell_out_spec.rb index c0af8ab48e..7fc8dc5957 100644 --- a/spec/functional/mixin/powershell_out_spec.rb +++ b/spec/functional/mixin/powershell_out_spec.rb @@ -22,13 +22,13 @@ describe Chef::Mixin::PowershellOut, windows_only: true do include Chef::Mixin::PowershellOut describe "#powershell_out" do - context "for windows version less than 10", windows_10_or_2016: false do + context "for windows version less than 10", windows_lt_10: true do it "runs a powershell command and collects stdout" do expect(powershell_out("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+VM\(M\)\s+CPU\(s\)\s+Id\s+/ end end - context "for windows version greater than 10", windows_10_or_2016: true do + context "for windows version greater than 10", windows_gte_10: true do it "runs a powershell command and collects stdout" do expect(powershell_out("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+CPU\(s\)\s+Id\s+SI\s+ProcessName\s+/ end @@ -40,13 +40,13 @@ describe Chef::Mixin::PowershellOut, windows_only: true do end describe "#powershell_out!" do - context "for windows version less than 10", windows_10_or_2016: false do + context "for windows version less than 10", windows_lt_10: true do it "runs a powershell command and collects stdout" do expect(powershell_out!("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+VM\(M\)\s+CPU\(s\)\s+Id\s+/ end end - context "for windows version less than 10", windows_10_or_2016: true do + context "for windows version less than 10", windows_gte_10: true do it "runs a powershell command and collects stdout" do expect(powershell_out("get-process").run_command.stdout).to match /Handles\s+NPM\(K\)\s+PM\(K\)\s+WS\(K\)\s+CPU\(s\)\s+Id\s+SI\s+ProcessName\s+/ end diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb index 00f0e61a34..03c14382e9 100644 --- a/spec/functional/resource/group_spec.rb +++ b/spec/functional/resource/group_spec.rb @@ -58,7 +58,6 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte when "debian", "fedora", "rhel", "suse", "gentoo", "slackware", "arch" expect { Etc.getgrnam(group) }.to raise_error(ArgumentError, "can't find group for #{group}") when "windows" - sleep(5) expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.to raise_error(ArgumentError, /The group name could not be found./) end end @@ -336,19 +335,6 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestree" end end end - describe "when group name length is more than 256", :windows_only do - let!(:group_name) do - "theoldmanwalkingdownthestreetalwayshadagood\ -smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\ -theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\ -downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end - - it "should not create a group" do - expect { group_resource.run_action(:create) }.to raise_error(ArgumentError) - group_should_not_exist(group_name) - end - end - # not_supported_on_solaris because of the use of excluded_members describe "should raise an error when same member is included in the members and excluded_members", :not_supported_on_solaris do it "should raise an error" do @@ -360,6 +346,25 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end end end + # Note:This testcase is written separately from the `group create action` defined above because + # for group name > 256, Windows 2016 returns "The parameter is incorrect" + context "group create action: when group name length is more than 256", :windows_only do + let!(:group_name) do + "theoldmanwalkingdownthestreetalwayshadagood\ +smileonhisfacetheoldmanwalkingdownthestreetalwayshadagoodsmileonhisface\ +theoldmanwalkingdownthestreetalwayshadagoodsmileonhisfacetheoldmanwalking\ +downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" end + + it "should not create a group" do + expect { group_resource.run_action(:create) }.to raise_error(ArgumentError) + if windows_gte_10? + expect { Chef::Util::Windows::NetGroup.new(group_name).local_get_members }.to raise_error(ArgumentError, /The parameter is incorrect./) + else + group_should_not_exist(group_name) + end + end + end + describe "group remove action" do describe "when there is a group" do before do |