Skip to content

Commit

Permalink
added test for minimal application
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 8, 2014
1 parent b4a2919 commit f711943
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions t/mojo/daemon.t
Expand Up @@ -13,6 +13,25 @@ use Mojo::Server::Daemon;
use Mojo::UserAgent;
use Mojolicious;

package TestApp;
use Mojo::Base 'Mojo';

sub handler {
my ($self, $tx) = @_;
$tx->res->code(200);
$tx->res->body('Hello TestApp!');
$tx->resume;
}

package main;

# Minimal application
my $ua = Mojo::UserAgent->new;
$ua->server->app(TestApp->new);
my $tx = $ua->get('/');
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Hello TestApp!', 'right content';

# Timeout
{
is(Mojo::Server::Daemon->new->inactivity_timeout, 15, 'right value');
Expand Down Expand Up @@ -82,7 +101,7 @@ isa_ok $app->build_tx, 'Mojo::Transaction::HTTP', 'right class';

# Fresh application
$app = Mojolicious->new;
my $ua = Mojo::UserAgent->new(ioloop => Mojo::IOLoop->singleton);
$ua = Mojo::UserAgent->new(ioloop => Mojo::IOLoop->singleton);
is $ua->server->app($app)->app->moniker, 'mojolicious', 'right moniker';

# Silence
Expand Down Expand Up @@ -121,7 +140,7 @@ $app->routes->post(
$app->routes->any('/*whatever' => {text => 'Whatever!'});

# Normal request
my $tx = $ua->get('/normal/');
$tx = $ua->get('/normal/');
ok $tx->keep_alive, 'will be kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Whatever!', 'right content';
Expand Down

0 comments on commit f711943

Please sign in to comment.