Sha256: f4665453896c08d4eb8ea2fbb130f1ccf523800953f35115024aa006af6b4ac7

Contents?: true

Size: 1.17 KB

Versions: 20

Compression:

Stored size: 1.17 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/util/windows'

describe Puppet::Util::Windows::File, :if => Puppet::Util::Platform.windows? do
  include PuppetSpec::Files

  let(:nonexist_file) { 'C:\somefile\that\wont\ever\exist' }
  let(:invalid_file_attributes) { 0xFFFFFFFF } #define INVALID_FILE_ATTRIBUTES (DWORD (-1))

  describe "get_attributes" do
    it "should raise an error for files that do not exist by default" do
      expect {
        described_class.get_attributes(nonexist_file)
      }.to raise_error(Puppet::Error, /GetFileAttributes/)
    end

    it "should raise an error for files that do not exist when specified" do
      expect {
        described_class.get_attributes(nonexist_file, true)
      }.to raise_error(Puppet::Error, /GetFileAttributes/)
    end

    it "should not raise an error for files that do not exist when specified" do
      expect {
        described_class.get_attributes(nonexist_file, false)
      }.not_to raise_error
    end

    it "should return INVALID_FILE_ATTRIBUTES for files that do not exist when specified" do
      expect(described_class.get_attributes(nonexist_file, false)).to eq(invalid_file_attributes)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-4.5.3 spec/unit/util/windows/file_spec.rb
puppet-4.5.3-x86-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.3-x64-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.3-universal-darwin spec/unit/util/windows/file_spec.rb
puppet-4.5.2 spec/unit/util/windows/file_spec.rb
puppet-4.5.2-x86-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.2-x64-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.2-universal-darwin spec/unit/util/windows/file_spec.rb
puppet-4.5.1 spec/unit/util/windows/file_spec.rb
puppet-4.5.1-x86-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.1-x64-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.1-universal-darwin spec/unit/util/windows/file_spec.rb
puppet-4.5.0 spec/unit/util/windows/file_spec.rb
puppet-4.5.0-x86-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.0-x64-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.5.0-universal-darwin spec/unit/util/windows/file_spec.rb
puppet-4.4.2 spec/unit/util/windows/file_spec.rb
puppet-4.4.2-x86-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.4.2-x64-mingw32 spec/unit/util/windows/file_spec.rb
puppet-4.4.2-universal-darwin spec/unit/util/windows/file_spec.rb