summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppetlabs.com>2011-07-12 15:42:44 -0700
committerJacob Helwig <jacob@puppetlabs.com>2011-08-19 13:48:28 -0700
commitaf2446ad8ebf0c112901ea26efa37b06247c08b0 (patch)
treec876285eb3c8ab5f0f909a211ff28e12332446cf
parentd9c3b0f5ac1e8f7ccbdb4b4edd2fa3e93fe882a5 (diff)
downloadpuppet-af2446ad8ebf0c112901ea26efa37b06247c08b0.tar.gz
puppet-af2446ad8ebf0c112901ea26efa37b06247c08b0.tar.xz
puppet-af2446ad8ebf0c112901ea26efa37b06247c08b0.zip
(#8268) Fix resource harness spec tests
The windows file type requires that the path start with either a drive letter or UNC style path. Also Ruby's File implementation on windows only supports 0644 and 0444 permission bits (it doesn't differentiate between group and other, and it doesn't know about the execute bit). This commit maps the path and permissions used in the test to sensible values when running on windows. Paired-with: Jacob Helwig <jacob@puppetlabs.com> (cherry picked from commit 06e0208ec34285e0749c366c8a12817044d7d513)
-rwxr-xr-xspec/unit/transaction/resource_harness_spec.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/spec/unit/transaction/resource_harness_spec.rb b/spec/unit/transaction/resource_harness_spec.rb
index 20a42d27b..a594d3669 100755
--- a/spec/unit/transaction/resource_harness_spec.rb
+++ b/spec/unit/transaction/resource_harness_spec.rb
@@ -7,10 +7,14 @@ describe Puppet::Transaction::ResourceHarness do
include PuppetSpec::Files
before do
+ @mode_750 = Puppet.features.microsoft_windows? ? '644' : '750'
+ @mode_755 = Puppet.features.microsoft_windows? ? '644' : '755'
+ path = Puppet.features.microsoft_windows? ? "c:/my/file" : "/my/file"
+
@transaction = Puppet::Transaction.new(Puppet::Resource::Catalog.new)
- @resource = Puppet::Type.type(:file).new :path => "/my/file"
+ @resource = Puppet::Type.type(:file).new :path => path
@harness = Puppet::Transaction::ResourceHarness.new(@transaction)
- @current_state = Puppet::Resource.new(:file, "/my/file")
+ @current_state = Puppet::Resource.new(:file, path)
@resource.stubs(:retrieve).returns @current_state
@status = Puppet::Resource::Status.new(@resource)
Puppet::Resource::Status.stubs(:new).returns @status
@@ -148,8 +152,8 @@ describe Puppet::Transaction::ResourceHarness do
describe "when applying changes" do
[false, true].each do |noop_mode|; describe (noop_mode ? "in noop mode" : "in normal mode") do
- [nil, '750'].each do |machine_state|; describe (machine_state ? "with a file initially present" : "with no file initially present") do
- [nil, '750', '755'].each do |yaml_mode|
+ [nil, @mode_750].each do |machine_state|; describe (machine_state ? "with a file initially present" : "with no file initially present") do
+ [nil, @mode_750, @mode_755].each do |yaml_mode|
[nil, :file, :absent].each do |yaml_ensure|; describe "with mode=#{yaml_mode.inspect} and ensure=#{yaml_ensure.inspect} stored in state.yml" do
[false, true].each do |auditing_ensure|
[false, true].each do |auditing_mode|
@@ -157,7 +161,7 @@ describe Puppet::Transaction::ResourceHarness do
auditing.push(:mode) if auditing_mode
auditing.push(:ensure) if auditing_ensure
[nil, :file, :absent].each do |ensure_property| # what we set "ensure" to in the manifest
- [nil, '750', '755'].each do |mode_property| # what we set "mode" to in the manifest
+ [nil, @mode_750, @mode_755].each do |mode_property| # what we set "mode" to in the manifest
manifest_settings = {}
manifest_settings[:audit] = auditing if !auditing.empty?
manifest_settings[:ensure] = ensure_property if ensure_property