2 describe 'apt::source', :type => :define do
14 :required_packages => false,
16 :key_server => 'keyserver.ubuntu.com',
17 :key_content => false,
25 :location => 'http://example.com',
26 :release => 'precise',
28 :include_src => false,
29 :required_packages => 'apache',
31 :key_server => 'keyserver.debian.com',
33 :key_content => 'ABCD1234'
37 :key_server => 'keyserver.debian.com',
38 :key_content => false,
42 :location => 'http://example.com',
43 :release => 'precise',
53 :architecture => 'amd64',
56 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
58 default_params.merge(param_set)
62 {:lsbdistcodename => 'karmic'}
70 "/etc/apt/sources.list.d/#{title}.list"
74 content = "# #{title}"
75 if param_hash[:architecture]
76 arch = "[arch=#{param_hash[:architecture]}] "
78 content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
80 if param_hash[:include_src]
81 content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
86 it { should contain_apt__params }
88 it { should contain_file("#{title}.list").with({
89 'ensure' => param_hash[:ensure],
100 should contain_apt__pin(title).with({
101 "priority" => param_hash[:pin],
102 "before" => "File[#{title}.list]"
105 should_not contain_apt__pin(title).with({
106 "priority" => param_hash[:pin],
107 "before" => "File[#{title}.list]"
113 should contain_exec("apt_update").with({
114 "command" => "/usr/bin/apt-get update",
115 "refreshonly" => true
120 if param_hash[:required_packages]
121 should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
122 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
123 "subscribe" => "File[#{title}.list]",
124 "refreshonly" => true,
125 "before" => 'Exec[apt_update]',
128 should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
129 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
130 "subscribe" => "File[#{title}.list]",
131 "refreshonly" => true
138 should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
139 "key" => param_hash[:key],
140 "ensure" => :present,
141 "key_server" => param_hash[:key_server],
142 "key_content" => param_hash[:key_content],
143 "key_source" => param_hash[:key_source],
144 "before" => "File[#{title}.list]"
147 should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
148 "key" => param_hash[:key],
149 "ensure" => :present,
150 "key_server" => param_hash[:key_server],
151 "key_content" => param_hash[:key_content],
152 "key_source" => param_hash[:key_source],
153 "before" => "File[#{title}.list]"
159 describe "without release should raise a Puppet::Error" do
160 let(:default_params) { Hash.new }
161 let(:facts) { Hash.new }
162 it { expect { should raise_error(Puppet::Error) } }
163 let(:facts) { { :lsbdistcodename => 'lucid' } }
164 it { should contain_apt__source(title) }