1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
require 'spec_helper'
describe 'apt::pin', type: :define do
let :pre_condition do
'class { "apt": }'
end
let(:facts) do
{
os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
lsbdistid: 'Debian',
osfamily: 'Debian',
lsbdistcodename: 'wheezy',
puppetversion: Puppet.version,
}
end
let(:title) { 'my_pin' }
context 'with defaults' do
it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n}) }
end
context 'with set version' do
let :params do
{
'packages' => 'vim',
'version' => '1',
}
end
it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n}) }
end
context 'with set origin' do
let :params do
{
'packages' => 'vim',
'origin' => 'test',
}
end
it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n}) }
end
context 'without defaults' do
let :params do
{
'explanation' => 'foo',
'order' => 99,
'release' => '1',
'codename' => 'bar',
'release_version' => '2',
'component' => 'baz',
'originator' => 'foobar',
'label' => 'foobaz',
'priority' => 10,
}
end
it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n}) }
it {
is_expected.to contain_apt__setting('pref-my_pin').with('priority' => 99)
}
end
context 'with ensure absent' do
let :params do
{
'ensure' => 'absent',
}
end
it {
is_expected.to contain_apt__setting('pref-my_pin').with('ensure' => 'absent')
}
end
context 'with bad characters' do
let(:title) { 'such bad && wow!' }
it { is_expected.to contain_apt__setting('pref-such__bad____wow_') }
end
describe 'validation' do
context 'with invalid order' do
let :params do
{
'order' => 'foo',
}
end
it do
is_expected.to raise_error(Puppet::Error, %r{expects an Integer value, got String})
end
end
context 'with packages == * and version' do
let :params do
{
'version' => '1',
}
end
it do
is_expected.to raise_error(Puppet::Error, %r{parameter version cannot be used in general form})
end
end
context 'with packages == * and release and origin' do
let :params do
{
'origin' => 'test',
'release' => 'foo',
}
end
it do
is_expected.to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive})
end
end
context 'with specific release and origin' do
let :params do
{
'release' => 'foo',
'origin' => 'test',
'packages' => 'vim',
}
end
it do
is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
end
end
context 'with specific version and origin' do
let :params do
{
'version' => '1',
'origin' => 'test',
'packages' => 'vim',
}
end
it do
is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive})
end
end
end
end
|