diff options
author | Thom May <thom@chef.io> | 2016-01-19 11:30:38 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-01-20 15:29:06 +0000 |
commit | 354cfa12ce137ef9128fdc6d2fa789e4ad5a60c7 (patch) | |
tree | 1f01ff3c078a5669022d23964521f6e8c7f75036 /spec | |
parent | 8d9bbbcda3b39fd1e0c8d20693c186213fdc8ffe (diff) | |
download | chef-354cfa12ce137ef9128fdc6d2fa789e4ad5a60c7.tar.gz |
Add periodic action as the default
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/apt_update_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/provider/apt_update_spec.rb b/spec/unit/provider/apt_update_spec.rb index 6f89d1b94a..e234cca960 100644 --- a/spec/unit/provider/apt_update_spec.rb +++ b/spec/unit/provider/apt_update_spec.rb @@ -40,4 +40,24 @@ describe Chef::Provider::AptUpdate do expect(new_resource).to be_updated_by_last_action end end + + describe "#action_periodic" do + before do + allow(File).to receive(:exist?).with("/var/lib/apt/periodic/update-success-stamp").and_return(true) + end + + it "should run if the time stamp is old" do + expect(File).to receive(:mtime).with("/var/lib/apt/periodic/update-success-stamp").and_return(Time.now - 86_500) + expect(provider).to receive(:shell_out!).with("apt-get -q update") + provider.run_action(:periodic) + expect(new_resource).to be_updated_by_last_action + end + + it "should not run if the time stamp is new" do + expect(File).to receive(:mtime).with("/var/lib/apt/periodic/update-success-stamp").and_return(Time.now) + expect(provider).to_not receive(:shell_out!).with("apt-get -q update") + provider.run_action(:periodic) + expect(new_resource).to_not be_updated_by_last_action + end + end end |