Merge pull request #1010 from LTangaF/remove_frequency_collector
[puppet-modules/puppetlabs-apt.git] / spec / classes / apt_update_spec.rb
index c6336a9151c943347f4029eff026dc7a881cedbc..89ba942aac702dd2dd9f5d5e970db97c7fd5e1e0 100644 (file)
@@ -61,6 +61,36 @@ describe 'apt::update', type: :class do
         is_expected.to contain_exec('apt_update').with('refreshonly' => false)
       end
     end
+    context 'and Exec[apt_update] refreshonly is overridden to true and has recent run' do
+      let(:facts) do
+        {
+          os: {
+            family: 'Debian',
+            name: 'Debian',
+            release: {
+              major: '8',
+              full: '8.0',
+            },
+            distro: {
+              codename: 'jessie',
+              id: 'Debian',
+            },
+          },
+          apt_update_last_success: Time.now.to_i,
+        }
+      end
+      let(:pre_condition) do
+        "
+        class{'::apt': update => {'frequency' => 'always' },}
+        Exec <| title=='apt_update' |> { refreshonly => true }
+        "
+      end
+
+      it 'skips an apt-get update run' do
+        # set the apt_update exec's refreshonly attribute to false
+        is_expected.to contain_exec('apt_update').with('refreshonly' => true)
+      end
+    end
   end
   context "when apt::update['frequency']='reluctantly'" do
     {