Code Review
/
puppet-modules
/
puppetlabs-apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
(PUP-6856) Always define facts
[puppet-modules/puppetlabs-apt.git]
/
spec
/
defines
/
pin_spec.rb
diff --git
a/spec/defines/pin_spec.rb
b/spec/defines/pin_spec.rb
index 4b05cd1551aa9a0b6da29a5e758f8ccd2a1e1676..4f51cf3d715c181bb41b7ebc274faa937fc8376c 100644
(file)
--- a/
spec/defines/pin_spec.rb
+++ b/
spec/defines/pin_spec.rb
@@
-3,37
+3,27
@@
describe 'apt::pin', :type => :define do
let :pre_condition do
'class { "apt": }'
end
let :pre_condition do
'class { "apt": }'
end
- let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
+ let(:facts) { {
+ :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+ :lsbdistid => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ :puppetversion => Puppet.version,
+ } }
let(:title) { 'my_pin' }
context 'defaults' do
let(:title) { 'my_pin' }
context 'defaults' do
- it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: \*\nPin: release a=my_pin\nPin-Priority: 0\n/)}
- it { is_expected.to contain_file("my_pin.pref").with({
- 'ensure' => 'present',
- 'path' => '/etc/apt/preferences.d/my_pin.pref',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
+ 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/)}
end
context 'set version' do
let :params do
{
'packages' => 'vim',
end
context 'set version' do
let :params do
{
'packages' => 'vim',
- 'version' =>
'1'
,
+ 'version' =>
"1"
,
}
end
}
end
- it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
- it { is_expected.to contain_file("my_pin.pref").with({
- 'ensure' => 'present',
- 'path' => '/etc/apt/preferences.d/my_pin.pref',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
+ it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: version 1\nPin-Priority: 0\n/)}
end
context 'set origin' do
end
context 'set origin' do
@@
-43,15
+33,7
@@
describe 'apt::pin', :type => :define do
'origin' => 'test',
}
end
'origin' => 'test',
}
end
- it { is_expected.to contain_file("my_pin.pref").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
- it { is_expected.to contain_file("my_pin.pref").with({
- 'ensure' => 'present',
- 'path' => '/etc/apt/preferences.d/my_pin.pref',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
- })
- }
+ it { is_expected.to contain_apt__setting("pref-my_pin").with_content(/Explanation: : my_pin\nPackage: vim\nPin: origin test\nPin-Priority: 0\n/)}
end
context 'not defaults' do
end
context 'not defaults' do
@@
-68,13
+50,9
@@
describe 'apt::pin', :type => :define do
'priority' => 10,
}
end
'priority' => 10,
}
end
- 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/) }
- it { is_expected.to contain_file("my_pin.pref").with({
- 'ensure' => 'present',
- 'path' => '/etc/apt/preferences.d/99-my_pin.pref',
- 'owner' => 'root',
- 'group' => 'root',
- 'mode' => '0644',
+ 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/) }
+ it { is_expected.to contain_apt__setting("pref-my_pin").with({
+ 'priority' => 99,
})
}
end
})
}
end
@@
-85,7
+63,7
@@
describe 'apt::pin', :type => :define do
'ensure' => 'absent'
}
end
'ensure' => 'absent'
}
end
- it { is_expected.to contain_
file("my_pin.pref
").with({
+ it { is_expected.to contain_
apt__setting("pref-my_pin
").with({
'ensure' => 'absent',
})
}
'ensure' => 'absent',
})
}
@@
-93,7
+71,7
@@
describe 'apt::pin', :type => :define do
context 'bad characters' do
let(:title) { 'such bad && wow!' }
context 'bad characters' do
let(:title) { 'such bad && wow!' }
- it { is_expected.to contain_
file("such__bad____wow_.pref
") }
+ it { is_expected.to contain_
apt__setting("pref-such__bad____wow_
") }
end
describe 'validation' do
end
describe 'validation' do
@@
-105,8
+83,8
@@
describe 'apt::pin', :type => :define do
end
it do
expect {
end
it do
expect {
- is_expected.to compile
- }.to raise_error(Puppet::Error, /
Only integers are allowed
/)
+ subject.call
+ }.to raise_error(Puppet::Error, /
expects a value of type Integer
/)
end
end
end
end
@@
-118,7
+96,7
@@
describe 'apt::pin', :type => :define do
end
it do
expect {
end
it do
expect {
- is_expected.to compile
+ subject.call
}.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
end
end
}.to raise_error(Puppet::Error, /parameter version cannot be used in general form/)
end
end
@@
-132,7
+110,7
@@
describe 'apt::pin', :type => :define do
end
it do
expect {
end
it do
expect {
- is_expected.to compile
+ subject.call
}.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
end
end
}.to raise_error(Puppet::Error, /parameters release and origin are mutually exclusive/)
end
end
@@
-147,7
+125,7
@@
describe 'apt::pin', :type => :define do
end
it do
expect {
end
it do
expect {
- is_expected.to compile
+ subject.call
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
end
end
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
end
end
@@
-162,7
+140,7
@@
describe 'apt::pin', :type => :define do
end
it do
expect {
end
it do
expect {
- is_expected.to compile
+ subject.call
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
end
end
}.to raise_error(Puppet::Error, /parameters release, origin, and version are mutually exclusive/)
end
end