File: 01-backends-netasync.t

package info (click to toggle)
libfuture-http-perl 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 276 kB
  • sloc: perl: 1,320; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 1,005 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
#!perl -w
use strict;
use warnings;
use Test::More;

use Future::HTTP;

is( Future::HTTP->best_implementation(), 'Future::HTTP::Tiny', "The default backend is HTTP::Tiny");

# If we can load a backend, also make sure it can be chosen:
for my $known_implementation (['IO/Async.pm'    => 'Future::HTTP::NetAsync']) {
    my( $module_file, $implementation ) = @$known_implementation;
    if( eval { require $module_file; 1 } ) {
        if( eval "require $implementation; 1" ) {
            my $backend = Future::HTTP->best_implementation(
                $known_implementation,
                ['strict.pm' => 'fallback reached'],
            );
            is( $backend, $implementation, "$implementation is chosen and loadable if $module_file is loaded" );
        } else {
            my $err = $@;
            diag "Skipped check for $implementation backend: $err";
        };
    } else {
        my $err = $@;
        diag "Skipped check for $implementation backend: $err";
    };
};

done_testing();