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_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
11 it { is_expected.to contain_file("my_pin.pref").with({
12 'ensure' => 'present',
13 'path' => '/etc/apt/preferences.d/my_pin.pref',
21 context 'set version' do
28 it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
29 it { is_expected.to contain_file("my_pin.pref").with({
30 'ensure' => 'present',
31 'path' => '/etc/apt/preferences.d/my_pin.pref',
39 context 'set origin' do
46 it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
47 it { is_expected.to contain_file("my_pin.pref").with({
48 'ensure' => 'present',
49 'path' => '/etc/apt/preferences.d/my_pin.pref',
57 context 'not defaults' do
60 'explanation' => 'foo',
64 'release_version' => '2',
66 'originator' => 'foobar',
71 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/) }
72 it { is_expected.to contain_file("my_pin.pref").with({
73 'ensure' => 'present',
74 'path' => '/etc/apt/preferences.d/99-my_pin.pref',
82 context 'ensure absent' do
88 it { is_expected.to contain_file("my_pin.pref").with({
94 context 'bad characters' do
95 let(:title) { 'such bad && wow!' }
96 it { is_expected.to contain_file("such__bad____wow_.pref") }
99 describe 'validation' do
100 context 'invalid order' do
109 }.to raise_error(Puppet::Error, /Only integers are allowed/)
113 context 'packages == * and version' do
122 }.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
126 context 'packages == * and release and origin' do
136 }.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
140 context 'specific form with release and origin' do
151 }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
155 context 'specific form with version and origin' do
166 }.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)