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 describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
55 default_params.merge(param_set)
59 {:lsbdistcodename => 'karmic'}
67 "/etc/apt/sources.list.d/#{title}.list"
71 content = "# #{title}"
72 content << "\ndeb #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
73 if param_hash[:include_src]
74 content << "deb-src #{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
79 it { should contain_apt__params }
81 it { should contain_file("#{title}.list").with({
82 'ensure' => param_hash[:ensure],
93 should contain_apt__pin(title).with({
94 "priority" => param_hash[:pin],
95 "before" => "File[#{title}.list]"
98 should_not contain_apt__pin(title).with({
99 "priority" => param_hash[:pin],
100 "before" => "File[#{title}.list]"
106 should contain_exec("apt_update").with({
107 "command" => "/usr/bin/apt-get update",
108 "refreshonly" => true
113 if param_hash[:required_packages]
114 should 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
120 should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({
121 "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}",
122 "subscribe" => "File[#{title}.list]",
123 "refreshonly" => true
130 should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({
131 "key" => param_hash[:key],
132 "ensure" => :present,
133 "key_server" => param_hash[:key_server],
134 "key_content" => param_hash[:key_content],
135 "key_source" => param_hash[:key_source],
136 "before" => "File[#{title}.list]"
139 should_not 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]"
151 describe "without release should raise a Puppet::Error" do
152 let(:default_params) { Hash.new }
153 let(:facts) { Hash.new }
154 it { expect { should raise_error(Puppet::Error) } }
155 let(:facts) { { :lsbdistcodename => 'lucid' } }
156 it { should contain_apt__source(title) }