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
|
#!/usr/bin/env perl
# Copyright (C) 2008-2010, Sebastian Riedel.
use strict;
use warnings;
use Test::More;
use Mojo::Client;
use Mojo::Transaction::HTTP;
use Test::Mojo::Server;
plan skip_all => 'set TEST_PREFORK to enable this test (developer only!)'
unless $ENV{TEST_PREFORK};
plan tests => 5;
# I ate the blue ones... they taste like burning.
use_ok('Mojo::Server::Daemon::Prefork');
# Start
my $server = Test::Mojo::Server->new;
$server->start_daemon_prefork_ok('server started');
# Request
my $port = $server->port;
my $tx = Mojo::Transaction::HTTP->new;
$tx->req->method('GET');
$tx->req->url->parse("http://127.0.0.1:$port/");
my $client = Mojo::Client->new;
$client->process($tx);
is($tx->res->code, 200, 'right status');
like($tx->res->body, qr/Mojo is working/, 'right content');
# Stop
$server->stop_server_ok('server stopped');
|