Skip to content

Commit

Permalink
changed comment style in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 15, 2013
1 parent 3c28daa commit 7615e0b
Show file tree
Hide file tree
Showing 41 changed files with 579 additions and 954 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,10 +1,11 @@

3.80 2013-01-14
3.80 2013-01-15
- Deprecated Mojo::Util->html_escape in favor of Mojo::Util->xml_escape.
- Deprecated Mojo::ByteStream->html_escape in favor of
Mojo::ByteStream->xml_escape.
- Deprecated Mojo::Home->slurp_rel_file in favor of Mojo::Util->slurp.
- Improved documentation.
- Improved tests.
- Fixed support for multi byte entities in Mojo::Util.

3.79 2013-01-13
Expand Down
3 changes: 0 additions & 3 deletions t/mojo/app.t
Expand Up @@ -65,7 +65,6 @@ is $ua->app->moniker, 'mojolicious', 'right moniker';
# Silence
$app->log->level('fatal');

# POST /chunked
$app->routes->post(
'/chunked' => sub {
my $self = shift;
Expand All @@ -84,7 +83,6 @@ $app->routes->post(
}
);

# POST /upload
my ($local_address, $local_port, $remote_address, $remote_port);
$app->routes->post(
'/upload' => sub {
Expand All @@ -97,7 +95,6 @@ $app->routes->post(
}
);

# /*
$app->routes->any('/*whatever' => {text => 'Whatever!'});

# Normal request
Expand Down
3 changes: 0 additions & 3 deletions t/mojo/cgi.t
Expand Up @@ -9,10 +9,8 @@ use Mojolicious::Lite;
# Silence
app->log->level('fatal');

# GET /
get '/' => {text => 'Your Mojo is working!'};

# POST /chunked
post '/chunked' => sub {
my $self = shift;

Expand All @@ -29,7 +27,6 @@ post '/chunked' => sub {
$self->$cb;
};

# GET /params
get '/params' => sub {
my $self = shift;
$self->render_json($self->req->params->to_hash);
Expand Down
2 changes: 0 additions & 2 deletions t/mojo/psgi.t
Expand Up @@ -14,15 +14,13 @@ under sub {
shift->on(finish => sub { $ENV{MOJO_HELLO} = 'world' });
};

# GET /cookies
get '/cookies' => sub {
my $self = shift;
my $params = $self->req->params->to_hash;
for my $key (sort keys %$params) { $self->cookie($key, $params->{$key}) }
$self->render_text('nomnomnom');
};

# POST /params
post '/params' => sub {
my $self = shift;
$self->render_json($self->req->params->to_hash);
Expand Down
48 changes: 20 additions & 28 deletions t/mojo/user_agent.t
Expand Up @@ -16,10 +16,8 @@ use Mojolicious::Lite;
# Silence
app->log->level('fatal');

# GET /
get '/' => {text => 'works!'};

# GET /timeout
my $timeout = undef;
get '/timeout' => sub {
my $self = shift;
Expand All @@ -29,25 +27,21 @@ get '/timeout' => sub {
$self->render_later;
};

# GET /no_length
get '/no_length' => sub {
my $self = shift;
$self->finish('works too!');
$self->rendered(200);
};

# GET /no_content
get '/no_content' => {text => 'fail!', status => 204};

# GET /echo
get '/echo' => sub {
my $self = shift;
gzip \(my $uncompressed = $self->req->body), \my $compressed;
$self->res->headers->content_encoding($self->req->headers->accept_encoding);
$self->render_data($compressed);
};

# POST /echo
post '/echo' => sub {
my $self = shift;
$self->render_data($self->req->body);
Expand Down Expand Up @@ -126,7 +120,7 @@ is(Mojo::UserAgent->app, $dummy, 'application are equal');
Mojo::UserAgent->app(app);
is(Mojo::UserAgent->app, app, 'applications are equal again');

# GET / (clean up non-blocking requests)
# Clean up non-blocking requests
my $ua = Mojo::UserAgent->new;
my $get = my $post = '';
$ua->get('/' => sub { $get = pop->error });
Expand All @@ -140,7 +134,7 @@ my $time = time;
Mojo::IOLoop->start;
ok time < ($time + 10), 'stopped automatically';

# GET / (non-blocking)
# Non-blocking
$ua = Mojo::UserAgent->new(ioloop => Mojo::IOLoop->singleton);
my ($success, $code, $body);
$ua->get(
Expand All @@ -167,31 +161,29 @@ Mojo::IOLoop->start;
app->log->unsubscribe(message => $msg);
like $err, qr/error event works/, 'right error';

# GET / (HTTPS request without TLS support)
# HTTPS request without TLS support
my $tx = $ua->get($ua->app_url->scheme('https'));
ok $tx->error, 'has error';

# GET / (blocking)
# Blocking
$tx = $ua->get('/');
ok $tx->success, 'successful';
ok !$tx->kept_alive, 'kept connection not alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'works!', 'right content';

# GET / (again)
# Again
$tx = $ua->get('/');
ok $tx->success, 'successful';
ok $tx->kept_alive, 'kept connection alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'works!', 'right content';

# GET /
$tx = $ua->get('/');
ok $tx->success, 'successful';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'works!', 'right content';

# GET / (events)
# Events
my ($finished_req, $finished_tx, $finished_res);
$tx = $ua->build_tx(GET => '/');
ok !$tx->is_finished, 'transaction is not finished';
Expand All @@ -214,7 +206,7 @@ ok $tx->res->is_finished, 'response is finished';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'works!', 'right content';

# GET /no_length (missing Content-Length header)
# Missing Content-Length header
($finished_req, $finished_tx, $finished_res) = ();
$tx = $ua->build_tx(GET => '/no_length');
ok !$tx->is_finished, 'transaction is not finished';
Expand All @@ -240,22 +232,22 @@ ok !$tx->keep_alive, 'keep connection not alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'works too!', 'right content';

# GET /no_content (204 No Content)
# 204 No Content
$tx = $ua->get('/no_content');
ok $tx->success, 'successful';
ok !$tx->kept_alive, 'kept connection not alive';
ok $tx->keep_alive, 'keep connection alive';
is $tx->res->code, 204, 'right status';
is $tx->res->body, '', 'no content';

# GET / (connection was kept alive)
# Connection was kept alive
$tx = $ua->get('/');
ok $tx->success, 'successful';
ok $tx->kept_alive, 'kept connection alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'works!', 'right content';

# POST /echo (non-blocking form)
# Non-blocking form
($success, $code, $body) = ();
$ua->post_form(
'/echo' => {hello => 'world'} => sub {
Expand All @@ -271,7 +263,7 @@ ok $success, 'successful';
is $code, 200, 'right status';
is $body, 'hello=world', 'right content';

# POST /echo (non-blocking JSON)
# Non-blocking JSON
($success, $code, $body) = ();
$ua->post_json(
'/echo' => {hello => 'world'} => sub {
Expand All @@ -287,7 +279,7 @@ ok $success, 'successful';
is $code, 200, 'right status';
is $body, '{"hello":"world"}', 'right content';

# GET /timeout (built-in web server times out)
# Built-in web server times out
my $log = '';
$msg = app->log->on(message => sub { $log .= pop });
$tx = $ua->get('/timeout?timeout=0.25');
Expand All @@ -297,7 +289,7 @@ is $tx->error, 'Premature connection close', 'right error';
is $timeout, 1, 'finish event has been emitted';
like $log, qr/Inactivity timeout\./, 'right log message';

# GET /timeout (client times out)
# Client times out
$ua->once(
start => sub {
my ($ua, $tx) = @_;
Expand All @@ -313,7 +305,7 @@ $tx = $ua->get('/timeout?timeout=5');
ok !$tx->success, 'not successful';
is $tx->error, 'Inactivity timeout', 'right error';

# GET /echo (response exceeding message size limit)
# Response exceeding message size limit
$ua->once(
start => sub {
my ($ua, $tx) = @_;
Expand All @@ -325,13 +317,13 @@ ok !$tx->success, 'not successful';
is(($tx->error)[0], 'Maximum message size exceeded', 'right error');
is(($tx->error)[1], undef, 'no code');

# GET /does_not_exist (404 response)
# 404 response
$tx = $ua->get('/does_not_exist');
ok !$tx->success, 'not successful';
is(($tx->error)[0], 'Not Found', 'right error');
is(($tx->error)[1], 404, 'right code');

# GET / (introspect)
# Introspect
my $req = my $res = '';
my $start = $ua->on(
start => sub {
Expand Down Expand Up @@ -375,7 +367,7 @@ like $res, qr|^HTTP/.*200 OK.*works!$|s, 'right response';
$ua->unsubscribe(start => $start);
ok !$ua->has_subscribers('start'), 'unsubscribed successfully';

# GET /echo (stream with drain callback and compressed response)
# Stream with drain callback and compressed response
$tx = $ua->build_tx(GET => '/echo');
my $i = 0;
my ($stream, $drain);
Expand Down Expand Up @@ -404,7 +396,7 @@ is $tx->res->code, 200, 'right status';
is $tx->res->body, '0123456789', 'right content';
is $stream, 1, 'no leaking subscribers';

# GET / (nested non-blocking requests after blocking one, with custom URL)
# Nested non-blocking requests after blocking one, with custom URL
my @kept_alive;
$ua->get(
$ua->app_url => sub {
Expand All @@ -428,7 +420,7 @@ $ua->get(
Mojo::IOLoop->start;
is_deeply \@kept_alive, [undef, 1, 1], 'connections kept alive';

# GET / (simple nested non-blocking requests with timers)
# Simple nested non-blocking requests with timers
@kept_alive = ();
$ua->get(
'/' => sub {
Expand All @@ -448,7 +440,7 @@ $ua->get(
Mojo::IOLoop->start;
is_deeply \@kept_alive, [1, 1], 'connections kept alive';

# GET / (blocking request after non-blocking one, with custom URL)
# Blocking request after non-blocking one, with custom URL
$tx = $ua->get($ua->app_url);
ok $tx->success, 'successful';
ok !$tx->kept_alive, 'kept connection not alive';
Expand Down
1 change: 0 additions & 1 deletion t/mojo/user_agent_online.t
Expand Up @@ -23,7 +23,6 @@ use Mojo::UserAgent;
use Mojolicious::Lite;
use ojo;

# GET /remote_address
get '/remote_address' => sub {
my $self = shift;
$self->render(text => $self->tx->remote_address);
Expand Down
1 change: 0 additions & 1 deletion t/mojo/user_agent_tls.t
Expand Up @@ -22,7 +22,6 @@ use Mojolicious::Lite;
# Silence
app->log->level('fatal');

# GET /
get '/' => {text => 'works!'};

# Web server with valid certificates
Expand Down

0 comments on commit 7615e0b

Please sign in to comment.