Sha256: ed777c2395d162e80d2e25e64d288011f2f88e3844e36c9f35c0aaaba1f59221

Contents?: true

Size: 888 Bytes

Versions: 278

Compression:

Stored size: 888 Bytes

Contents

#! /usr/bin/env ruby
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)
  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

278 entries across 278 versions & 1 rubygems

Version Path
puppet-6.4.0 spec/unit/type/file/mtime_spec.rb
puppet-6.4.0-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.4.0-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.4.0-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-6.0.7 spec/unit/type/file/mtime_spec.rb
puppet-6.0.7-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.0.7-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.0.7-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-5.5.12 spec/unit/type/file/mtime_spec.rb
puppet-5.5.12-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-5.5.12-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-5.5.12-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-6.3.0 spec/unit/type/file/mtime_spec.rb
puppet-6.3.0-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.3.0-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.3.0-universal-darwin spec/unit/type/file/mtime_spec.rb
puppet-6.2.0 spec/unit/type/file/mtime_spec.rb
puppet-6.2.0-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.2.0-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-6.2.0-universal-darwin spec/unit/type/file/mtime_spec.rb