summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-06-30 06:54:29 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-06-30 06:54:29 +0000
commitdfc692d5cfbb26fdc6494d862c6c14691b7fe986 (patch)
tree15edb86e837dd6f81bb61ffc94a1de84cb07272f /t
parenta39274fe2de1263ba7fd9bcb8fd7b2ff977e060b (diff)
downloadurpmi-dfc692d5cfbb26fdc6494d862c6c14691b7fe986.tar
urpmi-dfc692d5cfbb26fdc6494d862c6c14691b7fe986.tar.gz
urpmi-dfc692d5cfbb26fdc6494d862c6c14691b7fe986.tar.bz2
urpmi-dfc692d5cfbb26fdc6494d862c6c14691b7fe986.tar.xz
urpmi-dfc692d5cfbb26fdc6494d862c6c14691b7fe986.zip
Functions to write proxy.cfg (and regression tests)
Diffstat (limited to 't')
-rw-r--r--t/cfg.t32
1 files changed, 30 insertions, 2 deletions
diff --git a/t/cfg.t b/t/cfg.t
index 45403e24..77c831ff 100644
--- a/t/cfg.t
+++ b/t/cfg.t
@@ -1,11 +1,13 @@
#!/usr/bin/perl
-use Test::More tests => 4;
+use Test::More 'no_plan';
use MDK::Common;
BEGIN { use_ok 'urpm::cfg' }
+BEGIN { use_ok 'urpm::download' }
my $file = 'testurpmi.cfg';
+my $proxyfile = $urpm::download::PROXY_CFG = 'testproxy.cfg';
open my $f, '>', $file or die $!;
print $f (my $cfgtext = <<URPMICFG);
{
@@ -52,4 +54,30 @@ $cfgtext2 =~ s/# generated.*\n//;
is( $cfgtext, $cfgtext2, 'config is the same' )
or system qw( diff -u ), $file, $file.2;
-END { unlink $file, $file.2 }
+open $f, '>', $proxyfile or die $!;
+print $f ($cfgtext = <<PROXYCFG);
+http_proxy=http://foo:8080/
+local:http_proxy=http://yoyodyne:8080/
+local:proxy_user=rafael:richard
+PROXYCFG
+close $f;
+
+my $p = get_proxy();
+is( $p->{http_proxy}, 'http://foo:8080/', 'read proxy' );
+ok( !defined $p->{user}, 'no user defined' );
+$p = get_proxy('local');
+is( $p->{http_proxy}, 'http://yoyodyne:8080/', 'read media proxy' );
+is( $p->{user}, 'rafael', 'proxy user' );
+is( $p->{pwd}, 'richard', 'proxy password' );
+ok( dump_proxy_config(), 'dump_proxy_config' );
+$cfgtext2 = cat_($proxyfile);
+$cfgtext2 =~ s/# generated.*\n//;
+is( $cfgtext, $cfgtext2, 'dumped correctly' );
+set_proxy_config(http_proxy => '');
+ok( dump_proxy_config(), 'dump_proxy_config erased' );
+$cfgtext2 = cat_($proxyfile);
+$cfgtext2 =~ s/# generated.*\n//;
+$cfgtext =~ s/^http_proxy.*\n//;
+is( $cfgtext, $cfgtext2, 'dumped correctly' );
+
+END { unlink $file, $file.2, $proxyfile }