File: Micro.t

package info (click to toggle)
percona-toolkit 3.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 106,712 kB
  • sloc: perl: 257,236; sql: 23,577; sh: 21,388; javascript: 6,322; makefile: 397; python: 62; awk: 38; sed: 1
file content (39 lines) | stat: -rw-r--r-- 1,132 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
33
34
35
36
37
38
39
#!/usr/bin/perl

BEGIN {
   die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
      unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
   unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
};

use strict;
use warnings FATAL => 'all';
use English qw(-no_match_vars);
use Test::More;

use HTTP::Micro;

local $EVAL_ERROR;
eval { require HTTP::Tiny };
if ( $EVAL_ERROR ) {
   plan skip_all => "HTTP::Tiny is not installed";
}

# Need a simple URL that won't try to do chunking.
for my $test_url ( "http://www.percona.com/robots.txt", "https://v.percona.com" ) {
   my $tiny     = HTTP::Tiny->new(max_redirect => 0)->request('GET', $test_url);
   my $micro    = HTTP::Micro->new->request('GET', $test_url);

   # Need to split and sort content, because v.percona.com returns data
   # in different order for each call
   my $tiny_content = join "\n", sort (split /\n/, $tiny->{content});
   my $micro_content = (join "\n", sort (split /\n/, $micro->{content}));
   like(
      $micro_content,
      qr/^\Q$tiny_content/,
      "HTTP::Micro == HTTP::Tiny for $test_url"
   );
}

done_testing;
exit;