2 describe 'apt::source', :type => :define do
13 :required_packages => false,
15 :key_server => 'keyserver.ubuntu.com',
16 :key_content => false,
24 :location => 'somewhere',
25 :release => 'precise',
27 :include_src => false,
28 :required_packages => 'apache',
30 :key_server => 'keyserver.debian.com',
32 :key_content => 'ABCD1234'
36 :key_server => 'keyserver.debian.com',
37 :key_content => false,
40 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
42 default_params.merge(param_set)
46 {:lsbdistcodename => 'karmic'}
54 "/etc/apt/sources.list.d/#{title}.list"
58 content = "# #{title}"
59 content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
60 if param_hash[:include_src]
61 content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
66 it { should contain_apt__params }
68 it { should contain_file("#{title}.list").with({
80 should contain_apt__pin(param_hash[:release]).with({
81 "priority" => param_hash[:pin],
82 "before" => "File[#{title}.list]"
85 should_not contain_apt__pin(param_hash[:release]).with({
86 "priority" => param_hash[:pin],
87 "before" => "File[#{title}.list]"
93 should contain_exec("#{title} apt update").with({
94 "command" => "/usr/bin/apt-get update",
95 "subscribe" => "File[#{title}.list]",
101 if param_hash[:required_packages]
102 should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
103 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
104 "subscribe" => "File[#{title}.list]",
105 "refreshonly" => true
108 should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
109 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
110 "subscribe" => "File[#{title}.list]",
111 "refreshonly" => true
118 should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
119 "key" => param_hash[:key],
120 "ensure" => :present,
121 "key_server" => param_hash[:key_server],
122 "key_content" => param_hash[:key_content],
123 "key_source" => param_hash[:key_source],
124 "before" => "File[#{title}.list]"
127 should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
128 "key" => param_hash[:key],
129 "ensure" => :present,
130 "key_server" => param_hash[:key_server],
131 "key_content" => param_hash[:key_content],
132 "key_source" => param_hash[:key_source],
133 "before" => "File[#{title}.list]"
139 describe "without release should raise a Puppet::Error" do
140 let(:default_params) { Hash.new }
141 let(:facts) { Hash.new }
142 it { expect { should raise_error(Puppet::Error) } }
143 let(:facts) { { :lsbdistcodename => 'lucid' } }
144 it { should contain_apt__source(title) }