summaryrefslogtreecommitdiffstats
path: root/t/mojo-example.t
diff options
context:
space:
mode:
Diffstat (limited to 't/mojo-example.t')
-rw-r--r--t/mojo-example.t29
1 files changed, 16 insertions, 13 deletions
diff --git a/t/mojo-example.t b/t/mojo-example.t
index 8ed4835da..62dd83340 100644
--- a/t/mojo-example.t
+++ b/t/mojo-example.t
@@ -11,23 +11,24 @@ use 5.10.1;
use lib qw( . lib local/lib/perl5 );
BEGIN {
- $ENV{LOG4PERL_CONFIG_FILE} = 'log4perl-t.conf';
- # There's a plugin called Hostage that makes the application require specific Host: headers.
- # we disable that for these tests.
- $ENV{BUGZILLA_DISABLE_HOSTAGE} = 1;
+ $ENV{LOG4PERL_CONFIG_FILE} = 'log4perl-t.conf';
+
+# There's a plugin called Hostage that makes the application require specific Host: headers.
+# we disable that for these tests.
+ $ENV{BUGZILLA_DISABLE_HOSTAGE} = 1;
}
# this provides a default urlbase.
# Most localconfig options the other Bugzilla::Test::Mock* modules take care for us.
-use Bugzilla::Test::MockLocalconfig ( urlbase => 'http://bmo-web.vm' );
+use Bugzilla::Test::MockLocalconfig (urlbase => 'http://bmo-web.vm');
# This configures an in-memory sqlite database.
use Bugzilla::Test::MockDB;
# This redirects reads and writes from the config file (data/params)
use Bugzilla::Test::MockParams (
- phabricator_enabled => 1,
- announcehtml => '<div id="announcement">Mojo::Test is awesome</div>',
+ phabricator_enabled => 1,
+ announcehtml => '<div id="announcement">Mojo::Test is awesome</div>',
);
# Util provides a few functions more making mock data in the DB.
@@ -38,7 +39,7 @@ use Test2::Tools::Mock;
use Test::Mojo;
my $api_user = create_user('api@mozilla.org', '*');
-my $api_key = issue_api_key('api@mozilla.org')->api_key;
+my $api_key = issue_api_key('api@mozilla.org')->api_key;
# Mojo::Test loads the application and provides methods for
# testing requests without having to run a server.
@@ -55,22 +56,24 @@ $t->get_ok('/__lbheartbeat__')->status_is(200)->content_is('httpd OK');
# we can use json_is or json_like to check APIs.
# The first pair to json_like is a JSON pointer (RFC 6901)
-$t->get_ok('/bzapi/configuration')->status_is(200)->json_like( '/announcement' => qr/Mojo::Test is awesome/ );
+$t->get_ok('/bzapi/configuration')->status_is(200)
+ ->json_like('/announcement' => qr/Mojo::Test is awesome/);
# for web requests, you use text_like (or text_is) with CSS selectors.
-$t->get_ok('/')->status_is(200)->text_like( '#announcement' => qr/Mojo::Test is awesome/ );
+$t->get_ok('/')->status_is(200)
+ ->text_like('#announcement' => qr/Mojo::Test is awesome/);
# Chaining is not magical, you can break up longer lines
# by calling methods on $t, as below.
-$t->get_ok('/rest/whoami' => { 'X-Bugzilla-API-Key' => $api_key });
+$t->get_ok('/rest/whoami' => {'X-Bugzilla-API-Key' => $api_key});
$t->status_is(200);
$t->json_is('/name' => $api_user->login);
-$t->json_is('/id' => $api_user->id);
+$t->json_is('/id' => $api_user->id);
# Each time you call $t->get_ok, post_ok, etc the previous request is cleared.
$t->get_ok('/rest/whoami');
$t->status_is(200);
$t->json_is('/name' => '');
-$t->json_is('/id' => 0);
+$t->json_is('/id' => 0);
done_testing;