2012-01-04 02:03:24 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'apt::ppa', :type => :define do
|
2012-02-24 23:03:51 +01:00
|
|
|
['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
|
2012-01-04 02:03:24 +01:00
|
|
|
describe "with title #{t}" do
|
|
|
|
let :pre_condition do
|
|
|
|
'class { "apt": }'
|
|
|
|
end
|
2012-02-24 23:03:51 +01:00
|
|
|
let :facts do
|
|
|
|
{:lsbdistcodename => 'natty'}
|
|
|
|
end
|
2012-01-04 02:03:24 +01:00
|
|
|
let :title do
|
|
|
|
t
|
|
|
|
end
|
2012-02-24 23:03:51 +01:00
|
|
|
let :release do
|
|
|
|
"natty"
|
|
|
|
end
|
|
|
|
let :filename do
|
|
|
|
t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
|
2012-01-04 02:03:24 +01:00
|
|
|
end
|
2012-02-24 23:03:51 +01:00
|
|
|
|
2012-05-04 00:44:17 +02:00
|
|
|
it { should contain_exec("apt_update").with(
|
2012-05-03 06:35:13 +02:00
|
|
|
'command' => '/usr/bin/apt-get update',
|
2012-02-24 23:03:51 +01:00
|
|
|
'refreshonly' => true
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2012-01-04 02:03:24 +01:00
|
|
|
it { should contain_exec("add-apt-repository-#{t}").with(
|
|
|
|
'command' => "/usr/bin/add-apt-repository #{t}",
|
2012-05-04 00:44:17 +02:00
|
|
|
'notify' => "Exec[apt_update]",
|
2012-02-24 23:03:51 +01:00
|
|
|
'creates' => "/etc/apt/sources.list.d/#{filename}"
|
2012-01-04 02:03:24 +01:00
|
|
|
)
|
|
|
|
}
|
2012-02-24 23:03:51 +01:00
|
|
|
|
|
|
|
it { should create_file("/etc/apt/sources.list.d/#{filename}").with(
|
|
|
|
'ensure' => 'file',
|
|
|
|
'require' => "Exec[add-apt-repository-#{t}]"
|
2012-01-04 02:03:24 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
|
|
|
describe "without Class[apt] should raise a Puppet::Error" do
|
2012-02-24 23:03:51 +01:00
|
|
|
let(:release) { "natty" }
|
2012-01-23 22:08:00 +01:00
|
|
|
let(:title) { "ppa" }
|
2012-02-04 02:24:09 +01:00
|
|
|
it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) }
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|
2012-02-24 23:03:51 +01:00
|
|
|
|
|
|
|
describe "without release should raise a Puppet::Error" do
|
|
|
|
let(:title) { "ppa:" }
|
|
|
|
it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) }
|
|
|
|
end
|
|
|
|
|
2012-01-04 02:03:24 +01:00
|
|
|
end
|