summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2016-11-03 15:54:46 +0100
committervarac <varacanero@zeromail.org>2016-11-04 10:16:29 +0100
commitc7581a1f0e2b64b186a2d7c37e7ba0a9fa2cc1df (patch)
treee58bac6baf47d069f646bd78519550f4fb0d39a6 /spec
parent92f7340f30ddee7cedd6c70827c763189478de74 (diff)
Fix preferences_snippet.pp for puppet 4
Diffstat (limited to 'spec')
-rw-r--r--spec/defines/preferences_snippet_spec.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/defines/preferences_snippet_spec.rb b/spec/defines/preferences_snippet_spec.rb
new file mode 100644
index 0000000..012a5f6
--- /dev/null
+++ b/spec/defines/preferences_snippet_spec.rb
@@ -0,0 +1,66 @@
+require 'spec_helper'
+describe 'apt::preferences_snippet', :type => :define do
+ let :pre_condition do
+ 'class { "apt": }'
+ end
+ let(:facts) { {
+ :lsbdistid => 'Debian',
+ :osfamily => 'Debian',
+ :operatingsystem => 'Debian',
+ :debian_release => 'jessie',
+ :debian_codename => 'jessie',
+ :lsbdistcodename => 'jessie',
+ :virtual => 'physical',
+ :puppetversion => Puppet.version, } }
+ let :title do
+ 'test'
+ end
+
+ describe "when creating a preferences_snippet" do
+ let :default_params do
+ {
+ :ensure => 'present',
+ :release => "jessie-backports",
+ :priority => '999'
+ }
+ end
+ let :params do
+ default_params
+ end
+ let :filename do
+ "/etc/apt/preferences.d/test"
+ end
+
+ it { is_expected.to contain_file(filename).with({
+ 'ensure' => 'present',
+ 'content' => /Package: test\nPin: release a=jessie-backports\nPin-Priority: 999/,
+ 'owner' => 'root',
+ 'group' => '0',
+ 'mode' => '0644',
+ })
+ }
+
+ end
+
+ describe "when using both pin and release parameters" do
+ let :default_params do
+ {
+ :ensure => 'present',
+ :priority => '999',
+ :release => "jessie-backports",
+ :pin => '1.0'
+ }
+ end
+ let :params do
+ default_params
+ end
+ let :filename do
+ "/etc/apt/preferences.d/test"
+ end
+
+ it 'fails' do
+ expect { subject.call } .to raise_error(Puppet::Error, /apt::preferences_snippet requires either a 'pin' or 'release' argument, not both/)
+ end
+ end
+
+end