Sha256: 49c80be6c197e99914abdd9abfce95b0883e3efa84b0eb88d4db964108f7491b

Contents?: true

Size: 872 Bytes

Versions: 44

Compression:

Stored size: 872 Bytes

Contents

require 'spec_helper'

describe Puppet::Type.type(:file).attrclass(:mtime) do
  require 'puppet_spec/files'
  include PuppetSpec::Files

  before do
    @filename = tmpfile('mtime')
    @resource = Puppet::Type.type(:file).new({:name => @filename})
  end

  it "should be able to audit the file's mtime" do
    File.open(@filename, "w"){ }

    @resource[:audit] = [:mtime]

    # this .to_resource audit behavior is magical :-(
    expect(@resource.to_resource[:mtime]).to eq(Puppet::FileSystem.stat(@filename).mtime.to_s)
  end

  it "should return absent if auditing an absent file" do
    @resource[:audit] = [:mtime]

    expect(@resource.to_resource[:mtime]).to eq(:absent)
  end

  it "should prevent the user from trying to set the mtime" do
    expect {
      @resource[:mtime] = Time.now.to_s
    }.to raise_error(Puppet::Error, /mtime is read-only/)
  end

end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/type/file/mtime_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-8.3.0-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-8.4.0 spec/unit/type/file/mtime_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-8.4.0-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-7.28.0 spec/unit/type/file/mtime_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-7.28.0-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-8.3.1 spec/unit/type/file/mtime_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-8.3.1-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-7.27.0 spec/unit/type/file/mtime_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-7.27.0-universal-darwin spec/unit/type/file/mtime_spec.rb