2 describe 'apt::source', :type => :define do
3 let(:facts) { { :lsbdistid => 'Debian' } }
15 :required_packages => false,
17 :key_server => 'keyserver.ubuntu.com',
18 :key_content => false,
26 :location => 'http://example.com',
27 :release => 'precise',
29 :include_src => false,
30 :required_packages => 'apache',
32 :key_server => 'keyserver.debian.com',
34 :key_content => 'ABCD1234'
38 :key_server => 'keyserver.debian.com',
39 :key_content => false,
43 :location => 'http://example.com',
44 :release => 'precise',
54 :architecture => 'amd64',
57 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
59 default_params.merge(param_set)
63 {:lsbdistcodename => 'karmic', :lsbdistid => 'Ubuntu'}
71 "/etc/apt/sources.list.d/#{title}.list"
75 content = "# #{title}"
76 if param_hash[:architecture]
77 arch = "[arch=#{param_hash[:architecture]}] "
79 content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
81 if param_hash[:include_src]
82 content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
87 it { should contain_apt__params }
89 it { should contain_file("#{title}.list").with({
90 'ensure' => param_hash[:ensure],
101 should contain_apt__pin(title).with({
102 "priority" => param_hash[:pin],
103 "before" => "File[#{title}.list]"
106 should_not contain_apt__pin(title).with({
107 "priority" => param_hash[:pin],
108 "before" => "File[#{title}.list]"
114 should contain_exec("apt_update").with({
115 "command" => "/usr/bin/apt-get update",
116 "refreshonly" => true
121 if param_hash[:required_packages]
122 should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
123 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
124 "subscribe" => "File[#{title}.list]",
125 "refreshonly" => true,
126 "before" => 'Exec[apt_update]',
129 should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
130 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
131 "subscribe" => "File[#{title}.list]",
132 "refreshonly" => true
139 should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
140 "key" => param_hash[:key],
141 "ensure" => :present,
142 "key_server" => param_hash[:key_server],
143 "key_content" => param_hash[:key_content],
144 "key_source" => param_hash[:key_source],
145 "before" => "File[#{title}.list]"
148 should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
149 "key" => param_hash[:key],
150 "ensure" => :present,
151 "key_server" => param_hash[:key_server],
152 "key_content" => param_hash[:key_content],
153 "key_source" => param_hash[:key_source],
154 "before" => "File[#{title}.list]"
160 describe "without release should raise a Puppet::Error" do
161 let(:default_params) { Hash.new }
162 let(:facts) { Hash.new }
163 it { expect { should raise_error(Puppet::Error) } }
164 let(:facts) { { :lsbdistcodename => 'lucid', :lsbdistid => 'Ubuntu' } }
165 it { should contain_apt__source(title) }