2 describe 'apt::source', :type => :define do
14 :required_packages => false,
16 :key_server => 'keyserver.ubuntu.com',
17 :key_content => false,
25 :location => 'somewhere',
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 => 'somewhere',
43 :release => 'precise',
47 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
49 default_params.merge(param_set)
53 {:lsbdistcodename => 'karmic'}
61 "/etc/apt/sources.list.d/#{title}.list"
65 content = "# #{title}"
66 content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
67 if param_hash[:include_src]
68 content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
73 it { should contain_apt__params }
75 it { should contain_file("#{title}.list").with({
76 'ensure' => param_hash[:ensure],
87 should contain_apt__pin(param_hash[:release]).with({
88 "priority" => param_hash[:pin],
89 "before" => "File[#{title}.list]"
92 should_not contain_apt__pin(param_hash[:release]).with({
93 "priority" => param_hash[:pin],
94 "before" => "File[#{title}.list]"
100 should contain_exec("apt_update").with({
101 "command" => "/usr/bin/apt-get update",
102 "refreshonly" => true
107 if param_hash[:required_packages]
108 should 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
114 should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
115 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
116 "subscribe" => "File[#{title}.list]",
117 "refreshonly" => true
124 should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
125 "key" => param_hash[:key],
126 "ensure" => :present,
127 "key_server" => param_hash[:key_server],
128 "key_content" => param_hash[:key_content],
129 "key_source" => param_hash[:key_source],
130 "before" => "File[#{title}.list]"
133 should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
134 "key" => param_hash[:key],
135 "ensure" => :present,
136 "key_server" => param_hash[:key_server],
137 "key_content" => param_hash[:key_content],
138 "key_source" => param_hash[:key_source],
139 "before" => "File[#{title}.list]"
145 describe "without release should raise a Puppet::Error" do
146 let(:default_params) { Hash.new }
147 let(:facts) { Hash.new }
148 it { expect { should raise_error(Puppet::Error) } }
149 let(:facts) { { :lsbdistcodename => 'lucid' } }
150 it { should contain_apt__source(title) }