2 describe 'apt::pin', :type => :define do
6 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
7 let(:title) { 'my_pin' }
10 it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
11 it { is_expected.to contain_apt__setting("pref-my_pin").with({
12 'setting_type' => 'pref',
13 'base_name' => 'my_pin',
18 context 'set version' do
25 it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
26 it { is_expected.to contain_apt__setting("pref-my_pin").with({
27 'setting_type' => 'pref',
28 'base_name' => 'my_pin',
33 context 'set origin' do
40 it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
41 it { is_expected.to contain_apt__setting("pref-my_pin").with({
42 'setting_type' => 'pref',
43 'base_name' => 'my_pin',
48 context 'not defaults' do
51 'explanation' => 'foo',
55 'release_version' => '2',
57 'originator' => 'foobar',
62 it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
63 it { is_expected.to contain_apt__setting("pref-my_pin").with({
64 'setting_type' => 'pref',
65 'base_name' => 'my_pin',
71 context 'ensure absent' do
77 it { is_expected.to contain_apt__setting("pref-my_pin").with({
83 context 'bad characters' do
84 let(:title) { 'such bad && wow!' }
85 it { is_expected.to contain_apt__setting("pref-such__bad____wow_") }
88 describe 'validation' do
89 context 'invalid order' do
97 is_expected.to compile
98 }.to raise_error(Puppet::Error, /Only integers are allowed/)
102 context 'packages == * and version' do
110 is_expected.to compile
111 }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
115 context 'packages == * and release and origin' do
124 is_expected.to compile
125 }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
129 context 'specific form with release and origin' do
139 is_expected.to compile
140 }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
144 context 'specific form with version and origin' do
154 is_expected.to compile
155 }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)