File: http-program-control.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 (32 lines) | stat: -rw-r--r-- 1,040 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
26
27
28
29
30
31
32
#!/usr/bin/env perl
use Test2::V0;
use FindBin;
use lib $FindBin::Bin;

use App::Perlbrew::HTTP qw(http_user_agent_command);

for my $prog (qw(curl wget fetch)) {
    local $App::Perlbrew::HTTP::HTTP_USER_AGENT_PROGRAM = $prog;
    for my $verbose (0, 1) {
        local $App::Perlbrew::HTTP::HTTP_VERBOSE = $verbose;

        subtest "UA should be $prog, verbosity should be $verbose", sub {
            my ($ua, $cmd) = http_user_agent_command( "get" => { "url" => "https://perlbrew.pl" });

            is $ua, $prog, "UA Program can be set to: $prog";

            unless ($prog eq "fetch") {
                my ($cmd_verbosity) = $cmd =~ m/\s(--verbose)\s/;
                is !!$cmd_verbosity, !!$verbose, "verbosity matches: [$cmd]";
            }
        }
    };
}

subtest "something not supported", sub {
    local $App::Perlbrew::HTTP::HTTP_USER_AGENT_PROGRAM = "something-that-is-not-recognized";
    ok dies { http_user_agent_program() },
        "should die when asked to use unrecognized http UA program";
};

done_testing;