summaryrefslogtreecommitdiff
path: root/t/update_mirror.t
diff options
context:
space:
mode:
Diffstat (limited to 't/update_mirror.t')
-rw-r--r--t/update_mirror.t63
1 files changed, 63 insertions, 0 deletions
diff --git a/t/update_mirror.t b/t/update_mirror.t
new file mode 100644
index 0000000..c90cea2
--- /dev/null
+++ b/t/update_mirror.t
@@ -0,0 +1,63 @@
+use Test::More;
+use File::Spec::Functions;
+use strict;
+use warnings;
+
+use lib 't/lib';
+
+BEGIN {
+ eval "use CPANServer";
+
+ plan skip_all => "HTTP::Server::Simple required to test update_mirror"
+ if $@;
+ plan tests => 8;
+}
+
+use CPAN::Mini::Inject;
+use File::Path;
+
+rmtree( [ catdir( 't', 'mirror' ) ], 0, 1 );
+
+my $server = CPANServer->new( 11027 );
+my $pid = $server->background;
+ok( $pid, 'HTTP Server started' );
+sleep 1;
+
+$SIG{__DIE__} = sub { kill( 9, $pid ) };
+
+my $mcpi = CPAN::Mini::Inject->new;
+$mcpi->parsecfg( 't/.mcpani/config' );
+
+mkdir( catdir( 't', 'mirror' ) );
+
+$mcpi->update_mirror(
+ remote => 'http://localhost:11027',
+ local => catdir( 't', 'mirror' )
+);
+
+kill( 9, $pid );
+
+ok( -e catfile( qw(t mirror authors 01mailrc.txt.gz) ),
+ 'Mirrored 01mailrc.txt.gz' );
+ok( -e catfile( qw(t mirror modules 02packages.details.txt.gz) ),
+ 'Mirrored 02packages.details.txt.gz' );
+ok( -e catfile( qw(t mirror modules 03modlist.data.gz) ),
+ 'Mirrored 03modlist.data.gz' );
+
+ok( -e catfile( qw(t mirror authors id R RJ RJBS CHECKSUMS) ),
+ 'RJBS CHECKSUMS' );
+ok(
+ -e catfile(
+ qw(t mirror authors id R RJ RJBS CPAN-Mini-2.1828.tar.gz) ),
+ 'CPAN::Mini'
+);
+ok( -e catfile( qw(t mirror authors id S SS SSORICHE CHECKSUMS) ),
+ 'SSORICHE CHECKSUMS' );
+ok(
+ -e catfile(
+ qw(t mirror authors id S SS SSORICHE CPAN-Mini-Inject-1.01.tar.gz)
+ ),
+ 'CPAN::Mini::Inject'
+);
+sleep 1; # allow locks to expire
+rmtree( [ catdir( 't', 'mirror' ) ], 0, 1 );