summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2014-03-28 16:28:36 -0700
committerAdam Edwards <adamed@opscode.com>2014-03-29 00:21:13 -0700
commitbada8aeb8cdac4779a0d65d4d3fd9333910fc886 (patch)
treeeffffe837fe7140c955b6e18f0b5ff28761892c1 /spec/functional
parentdfe1ebf9bf59d02aa78c1fdef8787af1665a22fd (diff)
downloadchef-bada8aeb8cdac4779a0d65d4d3fd9333910fc886.tar.gz
CR feedback: move inheritance to class level, add tests for convert_boolean_true
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/resource/powershell_spec.rb67
1 files changed, 66 insertions, 1 deletions
diff --git a/spec/functional/resource/powershell_spec.rb b/spec/functional/resource/powershell_spec.rb
index d6df8b811e..9b5c498ea7 100644
--- a/spec/functional/resource/powershell_spec.rb
+++ b/spec/functional/resource/powershell_spec.rb
@@ -321,6 +321,20 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.should_skip?(:run).should be_false
end
+ it "inherits cwd from the parent resource for only_if" do
+ custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
+ resource.cwd custom_cwd
+ resource.only_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
+ resource.should_skip?(:run).should be_false
+ end
+
+ it "inherits cwd from the parent resource for not_if" do
+ custom_cwd = "#{ENV['SystemRoot']}\\system32\\drivers\\etc"
+ resource.cwd custom_cwd
+ resource.not_if "exit ! [int32]($pwd.path -eq '#{custom_cwd}')"
+ resource.should_skip?(:run).should be_true
+ end
+
it "evaluates a 64-bit resource with a 64-bit guard and interprets boolean false as zero status code", :windows64_only do
resource.architecture :x86_64
resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -ne 'AMD64')"
@@ -330,7 +344,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
it "evaluates a 64-bit resource with a 64-bit guard and interprets boolean true as nonzero status code", :windows64_only do
resource.architecture :x86_64
resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'AMD64')"
- resource.should_skip?(:run).should be_true
+ resource.should_skip?(:run).should be_true
end
it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code" do
@@ -344,6 +358,57 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.only_if "exit [int32]($env:PROCESSOR_ARCHITECTURE -eq 'X86')"
resource.should_skip?(:run).should be_true
end
+
+ it "evaluates a simple boolean false as nonzero status code when convert_boolean_return is true for only_if" do
+ resource.only_if "$false"
+ resource.should_skip?(:run).should be_true
+ end
+
+ it "evaluates a simple boolean true as nonzero status code when convert_boolean_return is true for not_if" do
+ resource.convert_boolean_return true
+ resource.not_if "$false"
+ resource.should_skip?(:run).should be_false
+ end
+
+ it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for only_if" do
+ resource.convert_boolean_return true
+ resource.only_if "$true"
+ resource.should_skip?(:run).should be_false
+ end
+
+ it "evaluates a simple boolean true as 0 status code when convert_boolean_return is true for not_if" do
+ resource.convert_boolean_return true
+ resource.not_if "$true"
+ resource.should_skip?(:run).should be_true
+ end
+
+ it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for only_if" do
+ resource.convert_boolean_return true
+ resource.architecture :i386
+ resource.only_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
+ resource.should_skip?(:run).should be_false
+ end
+
+ it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean false as zero status code using convert_boolean_return for not_if" do
+ resource.convert_boolean_return true
+ resource.architecture :i386
+ resource.not_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
+ resource.should_skip?(:run).should be_false
+ end
+
+ it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for only_if" do
+ resource.convert_boolean_return true
+ resource.architecture :i386
+ resource.only_if "$env:PROCESSOR_ARCHITECTURE -ne 'X86'"
+ resource.should_skip?(:run).should be_true
+ end
+
+ it "evaluates a 32-bit resource with a 32-bit guard and interprets boolean true as nonzero status code using convert_boolean_return for not_if" do
+ resource.convert_boolean_return true
+ resource.architecture :i386
+ resource.not_if "$env:PROCESSOR_ARCHITECTURE -eq 'X86'"
+ resource.should_skip?(:run).should be_true
+ end
end
def get_script_output