2 describe 'apt::ppa', :type => :define do
10 :lsbdistrelease => '11.04',
11 :lsbdistcodename => 'natty',
12 :operatingsystem => 'Ubuntu',
13 :osfamily => 'Debian',
14 :lsbdistid => 'Ubuntu',
18 let(:title) { 'ppa:needs/such.substitution/wow' }
19 it { is_expected.to contain_package('python-software-properties') }
20 it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
22 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
23 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
25 'logoutput' => 'on_failure',
29 it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({
35 describe 'package_name => software-properties-common' do
41 :package_name => 'software-properties-common'
46 :lsbdistrelease => '11.04',
47 :lsbdistcodename => 'natty',
48 :operatingsystem => 'Ubuntu',
49 :osfamily => 'Debian',
50 :lsbdistid => 'Ubuntu',
54 let(:title) { 'ppa:needs/such.substitution/wow' }
55 it { is_expected.to contain_package('software-properties-common') }
56 it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
58 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
59 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
61 'logoutput' => 'on_failure',
65 it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({
71 describe 'package_manage => false' do
77 :lsbdistrelease => '11.04',
78 :lsbdistcodename => 'natty',
79 :operatingsystem => 'Ubuntu',
80 :osfamily => 'Debian',
81 :lsbdistid => 'Ubuntu',
86 :package_manage => false,
90 let(:title) { 'ppa:needs/such.substitution/wow' }
91 it { is_expected.to_not contain_package('python-software-properties') }
92 it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
94 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
95 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
97 'logoutput' => 'on_failure',
101 it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({
107 describe 'apt included, no proxy' do
108 let :pre_condition do
113 :lsbdistrelease => '14.04',
114 :lsbdistcodename => 'trusty',
115 :operatingsystem => 'Ubuntu',
116 :lsbdistid => 'Ubuntu',
117 :osfamily => 'Debian',
125 let(:title) { 'ppa:foo' }
126 it { is_expected.to contain_package('software-properties-common') }
127 it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
129 'command' => '/usr/bin/add-apt-repository ppa:foo',
130 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
132 'logoutput' => 'on_failure',
136 it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
142 describe 'apt included, proxy' do
143 let :pre_condition do
144 'class { "apt": proxy_host => "example.com" }'
148 :lsbdistrelease => '14.04',
149 :lsbdistcodename => 'trusty',
150 :operatingsystem => 'Ubuntu',
151 :lsbdistid => 'Ubuntu',
152 :osfamily => 'Debian',
157 'release' => 'lucid',
160 let(:title) { 'ppa:foo' }
161 it { is_expected.to contain_package('software-properties-common') }
162 it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
163 'environment' => ['http_proxy=http://example.com:8080', 'https_proxy=http://example.com:8080'],
164 'command' => '/usr/bin/add-apt-repository -y ppa:foo',
165 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/foo-lucid.list',
167 'logoutput' => 'on_failure',
171 it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-lucid.list').that_requires('Exec[add-apt-repository-ppa:foo]').with({
177 describe 'ensure absent' do
180 :lsbdistrelease => '14.04',
181 :lsbdistcodename => 'trusty',
182 :operatingsystem => 'Ubuntu',
183 :lsbdistid => 'Ubuntu',
184 :osfamily => 'Debian',
187 let(:title) { 'ppa:foo' }
193 it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
194 'ensure' => 'absent',
199 context 'validation' do
200 describe 'no release' do
203 :lsbdistrelease => '14.04',
204 :operatingsystem => 'Ubuntu',
205 :lsbdistid => 'Ubuntu',
206 :osfamily => 'Debian',
209 let(:title) { 'ppa:foo' }
213 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
217 describe 'not ubuntu' do
220 :lsbdistrelease => '14.04',
221 :lsbdistcodename => 'trusty',
222 :operatingsystem => 'Debian',
223 :lsbdistid => 'Ubuntu',
224 :osfamily => 'Debian',
227 let(:title) { 'ppa:foo' }
231 }.to raise_error(Puppet::Error, /apt::ppa is currently supported on Ubuntu only./)