Created
December 18, 2011 12:09
-
-
Save inish777/1493207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Dancer/Plugin/Database.pm b/lib/Dancer/Plugin/Database.pm | |
index da8ecc9..6e94a52 100644 | |
--- a/lib/Dancer/Plugin/Database.pm | |
+++ b/lib/Dancer/Plugin/Database.pm | |
@@ -2,7 +2,6 @@ package Dancer::Plugin::Database; | |
use strict; | |
use Dancer::Plugin; | |
-use Dancer::Config; | |
use DBI; | |
use Dancer::Plugin::Database::Handle; | |
@@ -97,7 +96,6 @@ register database => sub { | |
} | |
}; | |
-register_plugin; | |
# Given the settings to use, try to get a database connection | |
sub _get_connection { | |
@@ -557,5 +555,5 @@ L<DBI> | |
L<Dancer::Plugin::SimpleCRUD> | |
=cut | |
- | |
+register_plugin; | |
1; # End of Dancer::Plugin::Database | |
diff --git a/lib/Dancer/Plugin/Database/Handle.pm b/lib/Dancer/Plugin/Database/Handle.pm | |
index 068f2b5..655f165 100644 | |
--- a/lib/Dancer/Plugin/Database/Handle.pm | |
+++ b/lib/Dancer/Plugin/Database/Handle.pm | |
@@ -4,7 +4,7 @@ use strict; | |
use Carp; | |
use DBI; | |
use base qw(DBI::db); | |
- | |
+use Dancer::Plugin; | |
our $VERSION = '0.07'; | |
=head1 NAME | |
diff --git a/t/00-load.t b/t/00-load.t | |
index 2561ca2..55fcbac 100644 | |
--- a/t/00-load.t | |
+++ b/t/00-load.t | |
@@ -1,10 +1,11 @@ | |
#!perl -T | |
-use Test::More tests => 1; | |
- | |
+use Dancer::Test; | |
+use Test::More; | |
BEGIN { | |
- use_ok( 'Dancer::Plugin::Database' ) || print "Bail out! | |
-"; | |
+ use_ok( 'Dancer::Plugin::Database' ) || print "Bail out!"; | |
+ use_ok ( 'Dancer::Plugin::Database::Handle ') || print "Bail out!"; | |
} | |
diag( "Testing Dancer::Plugin::Database $Dancer::Plugin::Database::VERSION, Perl $], $^X" ); | |
+done_testing; | |
diff --git a/t/01-basic.t b/t/01-basic.t | |
index 288b480..0a19a5a 100644 | |
--- a/t/01-basic.t | |
+++ b/t/01-basic.t | |
@@ -21,68 +21,68 @@ setting plugins => { Database => { dsn => $dsn, } }; | |
response_status_is [ GET => '/prepare_db' ], 200, 'db is created'; | |
response_status_is [ GET => '/' ], 200, "GET / is found"; | |
-response_content_like [ GET => '/' ], qr/3/, | |
+response_content_is [ GET => '/' ], qr/3/, | |
"content looks good for / (3 users afiter DB initialisation)"; | |
response_status_is [ GET => '/user/1' ], 200, 'GET /user/1 is found'; | |
-response_content_like [ GET => '/user/1' ], qr/sukria/, | |
+response_content_is [ GET => '/user/1' ], qr/sukria/, | |
'content looks good for /user/1'; | |
-response_content_like [ GET => '/user/2' ], qr/bigpresh/, | |
+response_content_is [ GET => '/user/2' ], qr/bigpresh/, | |
"content looks good for /user/2"; | |
response_status_is [ DELETE => '/user/3' ], 200, 'DELETE /user/3 is ok'; | |
-response_content_like [ GET => '/' ], qr/2/, | |
+response_content_is [ GET => '/' ], qr/2/, | |
'content looks good for / (2 users after deleting one)'; | |
# Exercise the extended features (quick_update et al) | |
response_status_is [ GET => '/quick_insert/42/Bob' ], 200, | |
"quick_insert returned OK status"; | |
-response_content_like [ GET => '/user/42' ], qr/Bob/, | |
+response_content_is [ GET => '/user/42' ], qr/Bob/, | |
"quick_insert created a record successfully"; | |
-response_content_like [ GET => '/quick_select/42' ], qr/Bob/, | |
+response_content_is [ GET => '/quick_select/42' ], qr/Bob/, | |
"quick_select returned the record created by quick_insert"; | |
-response_content_unlike [ GET => '/quick_select/69' ], qr/Bob/, | |
+response_content_isnt [ GET => '/quick_select/69' ], qr/Bob/, | |
"quick_select doesn't return non-matching record"; | |
-response_content_like [ GET => '/quick_select/1/category' ], qr/admin/, | |
+response_content_is [ GET => '/quick_select/1/category' ], qr/admin/, | |
'content looks good for /quick_select/1/category'; | |
-response_content_like [ GET => '/quick_select/2/name' ], qr/bigpresh/, | |
+response_content_is [ GET => '/quick_select/2/name' ], qr/bigpresh/, | |
'content looks good for /quick_select/2/name'; | |
-response_content_like [ GET => '/quick_lookup/bigpresh' ], qr/2/, | |
+response_content_is [ GET => '/quick_lookup/bigpresh' ], qr/2/, | |
'content looks good for /quick_lookup/bigpresh'; | |
-response_content_like [ GET => '/complex_where/42' ], qr/Bob/, | |
+response_content_is [ GET => '/complex_where/42' ], qr/Bob/, | |
"Complex where clause succeeded"; | |
-response_content_like [ GET => '/complex_not/42' ], qr/sukria/, | |
+response_content_is [ GET => '/complex_not/42' ], qr/sukria/, | |
"Complex not where clause succeeded"; | |
-response_content_like [ GET => '/set_op/2' ], qr/bigpresh/, | |
+response_content_is [ GET => '/set_op/2' ], qr/bigpresh/, | |
"set operation where clause succeeded"; | |
-response_content_like [ GET => '/quick_select_many' ], | |
+response_content_is [ GET => '/quick_select_many' ], | |
qr/\b bigpresh,sukria \b/x, | |
"quick_select returns multiple records in list context"; | |
response_status_is [ GET => '/quick_update/42/Billy' ], 200, | |
"quick_update returned OK status"; | |
-response_content_like [ GET => '/user/42' ], qr/Billy/, | |
+response_content_is [ GET => '/user/42' ], qr/Billy/, | |
"quick_update updated a record successfully"; | |
response_status_is [ GET => '/quick_delete/42' ], 200, | |
"quick_delete returned OK status"; | |
-response_content_like [ GET => '/user/42' ], qr/No such user/, | |
+response_content_is [ GET => '/user/42' ], qr/No such user/, | |
"quick_delete deleted a record successfully"; | |
# Test that runtime configuration gives us a handle, too: | |
response_status_is [ GET => '/runtime_config' ], 200, | |
"runtime_config returned OK status"; | |
-response_content_like [ GET => '/runtime_config' ], qr/ok/, | |
+response_content_is [ GET => '/runtime_config' ], qr/ok/, | |
"runtime_config got a usable database handle"; | |
# Test that we get the same handle each time we call the database() keyword | |
# (i.e., that handles are cached appropriately) | |
-response_content_like [ GET => '/handles_cached' ], qr/Same handle returned/; | |
+response_content_is [ GET => '/handles_cached' ], qr/Same handle returned/; | |
diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm | |
index 1ba42ee..176e61b 100644 | |
--- a/t/lib/TestApp.pm | |
+++ b/t/lib/TestApp.pm | |
@@ -11,7 +11,6 @@ get '/prepare_db' => sub { | |
q/insert into users values (2, 'bigpresh', 'admin')/, | |
q/insert into users values (3, 'badger', 'animal')/, | |
); | |
- | |
database->do($_) for @sql; | |
'ok'; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment