Alien-Base-ModuleBuild

 view release on metacpan or  search on metacpan

t/alien_base_modulebuild_repository_http.t  view on Meta::CPAN

subtest 'check_http_response()' => sub {

  subtest '599 no SSL' => sub {

    my $res = {
      'reason'  => 'Internal Exception',
      'url'     => 'https://mytest.test',
      'success' => '',
      'status'  => 599,
      'headers' => {
        'content-type' => 'text/plain',
        'content-length' => 110,
      },
      'content' => "IO::Socket::SSL 1.42 must be installed for https support\n" .
                   "Net::SSLeay 1.49 must be installed for https support\n",
    };

    is(
      [Alien::Base::ModuleBuild::Repository::HTTP->check_http_response($res)],
      [1, "IO::Socket::SSL 1.42 must be installed for https support\n" .
          "Net::SSLeay 1.49 must be installed for https support\n" .
          "See https://github.com/PerlAlien/Alien-Base-ModuleBuild/issues/6#issuecomment-417097485",
          { 'content-type' => 'text/plain', 'content-length' => 110 }, "https://mytest.test" ]
    );
  };

  subtest '599 other' => sub {

    my $res = {
      'reason'  => 'Internal Exception',
      'url'     => 'https://mytest.test',
      'success' => '',
      'status'  => 599,
      'headers' => {
        'content-type' => 'text/plain',
        'content-length' => 13,
      },
      'content' => "Some Error!\n",
    };

    is(
      [Alien::Base::ModuleBuild::Repository::HTTP->check_http_response($res)],
      [1, "Some Error!\n",
          { 'content-type' => 'text/plain', 'content-length' => 13 }, "https://mytest.test" ]
    );
  };

  subtest '404 bad url' => sub {

    my $res = {
      'headers' => {
        'content-type' => 'text/plain',
        'content-length' => length("404 Not Found\n"),
      },
      'url' => 'https://mytest.test/bogus',
      'protocol' => 'HTTP/1.1',
      'status' => '404',
      'success' => '',
      'reason' => 'Not Found',
      'content' => "404 Not Found\n",
    };

    is(
      [Alien::Base::ModuleBuild::Repository::HTTP->check_http_response($res)],
      [1, "404 Not Found",
          { 'content-type' => 'text/plain', 'content-length' => 14 }, "https://mytest.test/bogus" ],
    );

  };
};

done_testing;



( run in 0.909 second using v1.01-cache-2.11-cpan-70e19b8f4f1 )