Merge branch 'main' into IAC-1143
[puppet-modules/puppetlabs-apt.git] / spec / unit / facter / apt_update_last_success_spec.rb
1 require 'spec_helper'
2
3 describe 'apt_update_last_success fact' do
4   subject { Facter.fact(:apt_update_last_success).value }
5
6   before(:each) { Facter.clear }
7
8   describe 'on Debian based distro which has not yet created the update-success-stamp file' do
9     it 'has a value of -1' do
10       allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
11       allow(File).to receive(:exist?).with('/var/lib/apt/periodic/update-success-stamp').and_return(false)
12       is_expected.to eq(-1)
13     end
14   end
15
16   describe 'on Debian based distro which has created the update-success-stamp' do
17     it 'has the value of the mtime of the file' do
18       allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
19       allow(File).to receive(:exist?).and_return(true)
20       allow(File).to receive(:mtime).and_return(1_407_660_561)
21       is_expected.to eq(1_407_660_561)
22     end
23   end
24 end