2 describe 'apt::pin', :type => :define do
3 let(:facts) { { :lsbdistid => 'Debian' } }
4 let(:title) { 'my_pin' }
7 it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
8 it { is_expected.to contain_file("my_pin.pref").with({
10 'path' => '/etc/apt/preferences.d/my_pin.pref',
18 context 'set version' do
25 it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
26 it { is_expected.to contain_file("my_pin.pref").with({
27 'ensure' => 'present',
28 'path' => '/etc/apt/preferences.d/my_pin.pref',
36 context 'set origin' do
43 it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
44 it { is_expected.to contain_file("my_pin.pref").with({
45 'ensure' => 'present',
46 'path' => '/etc/apt/preferences.d/my_pin.pref',
54 context 'not defaults' do
57 'explanation' => 'foo',
61 'release_version' => '2',
63 'originator' => 'foobar',
68 it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n/) }
69 it { is_expected.to contain_file("my_pin.pref").with({
70 'ensure' => 'present',
71 'path' => '/etc/apt/preferences.d/99-my_pin.pref',
79 context 'ensure absent' do
85 it { is_expected.to contain_file("my_pin.pref").with({
91 context 'bad characters' do
92 let(:title) { 'such bad && wow!' }
93 it { is_expected.to contain_file("such__bad____wow_.pref") }
96 describe 'validation' do
97 context 'invalid order' do
106 }.to raise_error(Puppet::Error, /Only integers are allowed/)
110 context 'packages == * and version' do
119 }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
123 context 'packages == * and release and origin' do
133 }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
137 context 'specific form with release and origin' do
148 }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
152 context 'specific form with version and origin' do
163 }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)