File: error-http_download-exit-nonzero.t

package info (click to toggle)
perlbrew 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 752 kB
  • sloc: perl: 9,387; makefile: 7; sh: 1
file content (25 lines) | stat: -rw-r--r-- 649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env perl
use Test2::V0;

use File::Temp qw( tempdir );

my $actual_status_code = 42;

BEGIN {
    *CORE::GLOBAL::system = sub {
        return $? = $actual_status_code << 8;
    };
}

use App::Perlbrew::Path;
use App::Perlbrew::HTTP qw(http_download);

local $ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );

my $error = http_download( "https://example.com/whatever.tar.gz",
    App::Perlbrew::Path->new($App::perlbrew::PERLBREW_ROOT)->child("whatever.tar.gz") );

like $error, qr/^ERROR .+ Exit\ code: .+ ${actual_status_code}/xs,
    "The exit status code of curl is ${actual_status_code}";

done_testing;