1 # frozen_string_literal: true
27 let(:title) { 'ppa:needs/such.substitution/wow+type' }
29 it { is_expected.not_to contain_package('python-software-properties') }
31 is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with(environment: [],
32 command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type || (rm /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && false)', # rubocop:disable Layout/LineLength
33 unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow_type.gpg', # rubocop:disable Layout/LineLength
35 logoutput: 'on_failure')
39 describe 'Ubuntu 15.10 sources.list filename' do
57 let(:title) { 'ppa:user/foo' }
60 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [],
61 command: '/usr/bin/add-apt-repository -y ppa:user/foo || (rm /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && false)', # rubocop:disable Layout/LineLength
62 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user_ubuntu_foo.gpg', # rubocop:disable Layout/LineLength
64 logoutput: 'on_failure')
68 describe 'package_name => software-properties-common' do
74 package_name: 'software-properties-common',
95 let(:title) { 'ppa:needs/such.substitution/wow' }
97 it { is_expected.to contain_package('software-properties-common') }
99 is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
100 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength
101 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength
103 'logoutput' => 'on_failure')
107 is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
111 describe 'package_manage => false' do
112 let :pre_condition do
133 package_manage: false,
137 let(:title) { 'ppa:needs/such.substitution/wow' }
139 it { is_expected.not_to contain_package('python-software-properties') }
141 is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
142 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength
143 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength
145 'logoutput' => 'on_failure')
149 is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file')
153 describe 'apt included, no proxy' do
154 let :pre_condition do
156 apt::ppa { "ppa:user/foo2": }
178 package_manage: true,
179 require: 'Apt::Ppa[ppa:user/foo2]',
182 let(:title) { 'ppa:user/foo' }
184 it { is_expected.to compile.with_all_deps }
185 it { is_expected.to contain_package('software-properties-common') }
187 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [],
188 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
189 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
191 logoutput: 'on_failure')
195 describe 'apt included, proxy host' do
196 let :pre_condition do
198 proxy => { "host" => "localhost" },
220 'package_manage' => true,
223 let(:title) { 'ppa:user/foo' }
225 it { is_expected.to contain_package('software-properties-common') }
227 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8080'],
228 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
229 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
231 logoutput: 'on_failure')
235 describe 'apt included, proxy host and port' do
236 let :pre_condition do
238 proxy => { "host" => "localhost", "port" => 8180 },
260 package_manage: true,
263 let(:title) { 'ppa:user/foo' }
265 it { is_expected.to contain_package('software-properties-common') }
267 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180'],
268 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
269 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
271 logoutput: 'on_failure')
275 describe 'apt included, proxy host and port and https' do
276 let :pre_condition do
278 proxy => { "host" => "localhost", "port" => 8180, "https" => true },
300 package_manage: true,
303 let(:title) { 'ppa:user/foo' }
305 it { is_expected.to contain_package('software-properties-common') }
307 is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'],
308 command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength
309 unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength
311 logoutput: 'on_failure')
315 describe 'ensure absent' do
316 let :pre_condition do
335 let(:title) { 'ppa:user/foo' }
343 is_expected.to contain_file('/etc/apt/sources.list.d/user-foo-trusty.list').that_notifies('Class[Apt::Update]').with(ensure: 'absent')
347 context 'with validation' do
348 describe 'no release' do
365 let(:title) { 'ppa:user/foo' }
368 is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})
372 describe 'not ubuntu' do
389 let(:title) { 'ppa:user/foo' }
392 is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian})