X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-HTTP-AnyUA;a=blobdiff_plain;f=t%2F50-future-subclass.t;fp=t%2F50-future-subclass.t;h=619d7135054b7fd9970e9687c4212d7cef317355;hp=0000000000000000000000000000000000000000;hb=8306d573a50cbac0d76bf01ce98e82beec36e42d;hpb=950a5203bb27c21b549742ce3dec05df1e331b59 diff --git a/t/50-future-subclass.t b/t/50-future-subclass.t new file mode 100644 index 0000000..619d713 --- /dev/null +++ b/t/50-future-subclass.t @@ -0,0 +1,45 @@ +#!perl + +use warnings; +use strict; + +use lib 't/lib'; + +use HTTP::AnyUA; +use Test::More tests => 2; +use Util qw(test_user_agent); + +HTTP::AnyUA->register_backend(Mock => '+MockBackend'); + +subtest 'test Future::Mojo as a Future response' => sub { + test_user_agent 'Mojo::UserAgent' => sub { + plan tests => 1; + + my $ua = shift; + my $any_ua = HTTP::AnyUA->new($ua, response_is_future => 1); + + my $url = 'http://acme.tld/'; + + my $future = $any_ua->get($url); + isa_ok($future, 'Future::Mojo'); + + return $future; + }; +}; + +subtest 'test AnyEvent::Future as a Future response' => sub { + test_user_agent 'AnyEvent::HTTP' => sub { + plan tests => 1; + + my $ua = shift; + my $any_ua = HTTP::AnyUA->new($ua, response_is_future => 1); + + my $url = 'http://acme.tld/'; + + my $future = $any_ua->get($url); + isa_ok($future, 'AnyEvent::Future'); + + return $future; + }; +}; +