Skip to content

Commit 50e0b52

Browse files
committed
Merge pull request voxpupuli#183 from petems/fix_proxy_search
Fix proxy search
2 parents 508ccfc + 5e63090 commit 50e0b52

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

manifests/pip.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
# Latest version.
215215
exec { "pip_install_${name}":
216216
command => "${pip_env} wheel --help > /dev/null 2>&1 && { ${pip_env} wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { ${pip_env} --log ${log}/pip.log install --upgrade \$wheel_support_flag ${proxy_flag} ${install_args} ${install_editable} ${source} || ${pip_env} --log ${log}/pip.log install --upgrade ${proxy_flag} ${install_args} ${install_editable} ${source} ;}",
217-
unless => "${pip_env} search ${source} | grep -i INSTALLED | grep -i latest",
217+
unless => "${pip_env} search ${proxy_flag} ${source} | grep -i INSTALLED | grep -i latest",
218218
user => $owner,
219219
cwd => $cwd,
220220
environment => $environment,

spec/defines/pip_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,27 @@
3030
it { is_expected.to contain_exec("pip_install_rpyc").with_cwd('/') }
3131
end
3232
end
33+
34+
describe "proxy as" do
35+
context "defaults to empty" do
36+
let (:params) {{ }}
37+
it { is_expected.to contain_exec("pip_install_rpyc").without_command(/--proxy/) }
38+
end
39+
context "does not add proxy to search command if set to latest and proxy is unset" do
40+
let (:params) {{ :ensure => 'latest' }}
41+
it { is_expected.to contain_exec("pip_install_rpyc").without_command(/--proxy/) }
42+
it { is_expected.to contain_exec("pip_install_rpyc").without_unless(/--proxy/) }
43+
end
44+
context "adds proxy to install command if proxy set" do
45+
let (:params) {{ :proxy => "http://my.proxy:3128" }}
46+
it { is_expected.to contain_exec("pip_install_rpyc").with_command("pip wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { pip --log /tmp/pip.log install $wheel_support_flag --proxy=http://my.proxy:3128 rpyc || pip --log /tmp/pip.log install --proxy=http://my.proxy:3128 rpyc ;}") }
47+
end
48+
context "adds proxy to search command if set to latest" do
49+
let (:params) {{ :proxy => "http://my.proxy:3128", :ensure => 'latest' }}
50+
it { is_expected.to contain_exec("pip_install_rpyc").with_command("pip wheel --help > /dev/null 2>&1 && { pip wheel --version > /dev/null 2>&1 || wheel_support_flag='--no-use-wheel'; } ; { pip --log /tmp/pip.log install --upgrade $wheel_support_flag --proxy=http://my.proxy:3128 rpyc || pip --log /tmp/pip.log install --upgrade --proxy=http://my.proxy:3128 rpyc ;}") }
51+
it { is_expected.to contain_exec("pip_install_rpyc").with_unless('pip search --proxy=http://my.proxy:3128 rpyc | grep -i INSTALLED | grep -i latest') }
52+
end
53+
end
54+
3355
end
3456
end

0 commit comments

Comments
 (0)