diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-07-30 13:39:34 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2013-07-30 13:39:34 +0000 |
commit | 74e30d582ac01d80a7f1b28af247d0a5ee913d55 (patch) | |
tree | 2fdf53fd16ae0708e1180e4da06bea72a02175f0 /t/testremote.t | |
download | CPAN-Mini-Inject-tarball-master.tar.gz |
CPAN-Mini-Inject-0.33HEADCPAN-Mini-Inject-0.33master
Diffstat (limited to 't/testremote.t')
-rw-r--r-- | t/testremote.t | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/t/testremote.t b/t/testremote.t new file mode 100644 index 0000000..900d3e8 --- /dev/null +++ b/t/testremote.t @@ -0,0 +1,44 @@ +use Test::More; + +use LWP; +use CPAN::Mini::Inject; +use lib 't/lib'; + +BEGIN { + eval "use CPANServer"; + + plan skip_all => "HTTP::Server::Simple required to test update_mirror" + if $@; + plan tests => 3; +} + +my $server = CPANServer->new( 11027 ); +my $pid = $server->background; +ok( $pid, 'HTTP Server started' ); +# Give server time to get going. +sleep 1; + +$SIG{__DIE__} = sub { kill( 9, $pid ) }; + +my $mcpi = CPAN::Mini::Inject->new; +$mcpi->loadcfg( 't/.mcpani/config' )->parsecfg; + +$mcpi->testremote; +is( $mcpi->{site}, 'http://localhost:11027/', 'Correct remote URL' ); + +$mcpi->loadcfg( 't/.mcpani/config_badremote' )->parsecfg; + +SKIP: { + skip 'Test fails with funky DNS providers', 1 + if can_fetch( 'http://blahblah' ); + # This fails with OpenDNS &c + $mcpi->testremote; + is( $mcpi->{site}, 'http://localhost:11027/', + 'Selects correct remote URL' ); +} + +kill( 9, $pid ); + +unlink( 't/testconfig' ); + +sub can_fetch { LWP::UserAgent->new->get( shift )->is_success } |