]> Dogcows Code - chaz/p5-HTTP-AnyUA/blobdiff - t/50-future-subclass.t
respond with Future subclasses
[chaz/p5-HTTP-AnyUA] / t / 50-future-subclass.t
diff --git a/t/50-future-subclass.t b/t/50-future-subclass.t
new file mode 100644 (file)
index 0000000..619d713
--- /dev/null
@@ -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;
+    };
+};
+
This page took 0.018945 seconds and 4 git commands to generate.