From 997c9fdc40919fb3a2949eaa3fd6c60ab7432baa Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 13 Feb 2012 09:58:30 -0800 Subject: [PATCH] (#12529) Add unit test for apt proxy settings This commit adds unit tests to validate that the apt proxy is configured as expected when the class parameter proxy_host is set as a class parameter for the apt class. --- spec/classes/apt_spec.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 5ac64f2..1c7c18f 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -10,7 +10,9 @@ describe 'apt', :type => :class do [{}, { :disable_keys => true, - :always_apt_update => true + :always_apt_update => true, + :proxy_host => true, + :proxy_port => '3128' } ].each do |param_set| describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do @@ -74,6 +76,18 @@ describe 'apt', :type => :class do }) end } + describe 'when setting a proxy' do + it { + if param_hash[:proxy_host] + should contain_file('configure-apt-proxy').with( + 'path' => '/etc/apt/apt.conf.d/proxy', + 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";" + ) + else + should_not contain_file('configure_apt_proxy') + end + } + end end end end -- 2.45.2