Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test that database_connected hook fires correctly

  • Loading branch information...
commit 900427ed5c16cea6eb036e64eabdc6b27e1897b8 1 parent 3fad92b
@bigpresh bigpresh authored
Showing with 13 additions and 2 deletions.
  1. +5 −2 t/01-basic.t
  2. +8 −0 t/lib/TestApp.pm
View
7 t/01-basic.t
@@ -14,13 +14,16 @@ if ($@) {
plan skip_all => 'DBD::SQLite required to run these tests';
}
-plan tests => 32;
+plan tests => 33;
my $dsn = "dbi:SQLite:dbname=:memory:";
setting plugins => { Database => { dsn => $dsn, } };
-response_status_is [ GET => '/prepare_db' ], 200, 'db is created';
+response_content_is [ GET => '/connecthookfired' ], 1,
+ 'database_connect hook fires';
+
+response_status_is [ GET => '/prepare_db' ], 200, 'db is created';
response_status_is [ GET => '/' ], 200, "GET / is found";
response_content_like [ GET => '/' ], qr/5/,
View
8 t/lib/TestApp.pm
@@ -3,6 +3,14 @@ package t::lib::TestApp;
use Dancer;
use Dancer::Plugin::Database;
+
+hook database_connected => sub { vars->{connecthookfired} = 1; };
+
+get '/connecthookfired' => sub {
+ my $database = database();
+ return vars->{connecthookfired};
+};
+
get '/prepare_db' => sub {
my @sql = (
Please sign in to comment.
Something went wrong with that request. Please try again.