1 # frozen_string_literal: true
5 def ppa_exec_params(user, repo, distro = 'trusty', environment = [])
7 environment: environment,
8 command: "/opt/puppetlabs/puppet/cache/add-apt-repository-#{user}-ubuntu-#{repo}-#{distro}.sh",
9 logoutput: 'on_failure',
13 describe 'apt::ppa' do
18 describe 'defaults' do
36 let(:title) { 'ppa:needs/substitution' }
38 it { is_expected.not_to contain_package('python-software-properties') }
40 is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
41 .that_notifies('Class[Apt::Update]')
42 .with(*ppa_exec_params('needs', 'substitution'))
46 describe 'Ubuntu 15.10 sources.list filename' do
64 let(:title) { 'ppa:user/foo' }
67 is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
68 .that_notifies('Class[Apt::Update]')
69 .with(*ppa_exec_params('user', 'foo', 'wily'))
73 describe 'package_name => software-properties-common' do
80 package_name: 'software-properties-common',
102 let(:title) { 'ppa:needs/substitution' }
104 it { is_expected.to contain_package('software-properties-common') }
106 is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
107 .that_notifies('Class[Apt::Update]')
108 .with(*ppa_exec_params('needs', 'substitution'))
112 describe 'package_manage => false' do
113 let :pre_condition do
136 package_manage: false,
140 let(:title) { 'ppa:needs/substitution' }
142 it { is_expected.not_to contain_package('python-software-properties') }
144 is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution')
145 .that_notifies('Class[Apt::Update]')
146 .with(*ppa_exec_params('needs', 'substitution'))
150 describe 'apt included, no proxy' do
151 let :pre_condition do
153 apt::ppa { "ppa:user/foo2": }
176 package_manage: true,
177 require: 'Apt::Ppa[ppa:user/foo2]',
181 let(:title) { 'ppa:user/foo' }
183 it { is_expected.to compile.with_all_deps }
184 it { is_expected.to contain_package('software-properties-common') }
186 is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
187 .that_notifies('Class[Apt::Update]')
188 .with(*ppa_exec_params('user', 'foo'))
192 describe 'apt included, proxy host' do
193 let :pre_condition do
195 proxy => { "host" => "localhost" },
218 'package_manage' => true,
222 let(:title) { 'ppa:user/foo' }
224 it { is_expected.to contain_package('software-properties-common') }
226 is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
227 .that_notifies('Class[Apt::Update]')
228 .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8080']))
232 describe 'apt included, proxy host and port' do
233 let :pre_condition do
235 proxy => { "host" => "localhost", "port" => 8180 },
258 package_manage: true,
262 let(:title) { 'ppa:user/foo' }
264 it { is_expected.to contain_package('software-properties-common') }
266 is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
267 .that_notifies('Class[Apt::Update]')
268 .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180']))
272 describe 'apt included, proxy host and port and https' do
273 let :pre_condition do
275 proxy => { "host" => "localhost", "port" => 8180, "https" => true },
298 package_manage: true,
302 let(:title) { 'ppa:user/foo' }
304 it { is_expected.to contain_package('software-properties-common') }
306 is_expected.to contain_exec('add-apt-repository-ppa:user/foo')
307 .that_notifies('Class[Apt::Update]')
308 .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180']))
312 describe 'ensure absent' do
313 let :pre_condition do
334 let(:title) { 'ppa:user/foo' }
343 is_expected.to contain_tidy("remove-apt-repository-script-#{title}")
344 .with('path' => '/opt/puppetlabs/puppet/cache/add-apt-repository-user-ubuntu-foo-trusty.sh')
346 is_expected.to contain_tidy("remove-apt-repository-#{title}")
347 .with('path' => '/etc/apt/sources.list.d/user-ubuntu-foo-trusty.list')
348 .that_notifies('Class[Apt::Update]')
352 context 'with validation' do
353 describe 'no release' do
371 let(:title) { 'ppa:user/foo' }
374 is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
378 describe 'not ubuntu' do
396 let(:title) { 'ppa:user/foo' }
399 is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian})