[Catalyst-commits] r13360 - in Catalyst-Authentication-Store-DBIx-Class/trunk/t: . lib lib/TestApp/Model

rafl at dev.catalyst.perl.org rafl at dev.catalyst.perl.org
Wed Jun 16 21:10:33 GMT 2010


Author: rafl
Date: 2010-06-16 22:10:33 +0100 (Wed, 16 Jun 2010)
New Revision: 13360

Removed:
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/SetupDB.pm
Modified:
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/03-authtest.t
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/04-authsessions.t
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/05-auth-roles-relationship.t
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/06-auth-roles-column.t
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/07-authsessions-cached.t
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/08-simpledb-auth-roles-relationship.t
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/09-simpledb-auth-roles-column.t
   Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/TestApp/Model/TestApp.pm
Log:
Allow running tests in parallel

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/03-authtest.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/03-authtest.t	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/03-authtest.t	2010-06-16 21:10:33 UTC (rev 13360)
@@ -19,8 +19,6 @@
 
     plan tests => 17;
 
-    $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
     $ENV{TESTAPP_CONFIG} = {
         name => 'TestApp',
         authentication => {
@@ -46,8 +44,6 @@
     ];
 }
 
-use SetupDB;
-
 use Catalyst::Test 'TestApp';
 
 # log a user in
@@ -105,10 +101,3 @@
     my $res = request('http://localhost/user_login?username=joeuser&password=hackme');
     like( $res->content, qr/\$\Qc->model('Nonexistent::Class') did not return a resultset. Did you set user_model correctly?/, 'test for wrong user_class' );
 }
-	    
-	  
-
-
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/04-authsessions.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/04-authsessions.t	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/04-authsessions.t	2010-06-16 21:10:33 UTC (rev 13360)
@@ -21,7 +21,7 @@
         or plan skip_all =>
         "DBIx::Class is required for this test";
 
-    eval { require Catalyst::Plugin::Session; 
+    eval { require Catalyst::Plugin::Session;
            die unless $Catalyst::Plugin::Session::VERSION >= 0.02 }
         or plan skip_all =>
         "Catalyst::Plugin::Session >= 0.02 is required for this test";
@@ -33,8 +33,6 @@
 
     plan tests => 8;
 
-    $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
     $ENV{TESTAPP_CONFIG} = {
         name => 'TestApp',
         authentication => {
@@ -65,8 +63,6 @@
     ];
 }
 
-use SetupDB;
-
 use Test::WWW::Mechanize::Catalyst 'TestApp';
 my $m = Test::WWW::Mechanize::Catalyst->new;
 
@@ -93,6 +89,3 @@
     $m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
     $m->content_is( '', "user's session deleted" );
 }
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/05-auth-roles-relationship.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/05-auth-roles-relationship.t	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/05-auth-roles-relationship.t	2010-06-16 21:10:33 UTC (rev 13360)
@@ -23,9 +23,6 @@
 
     plan tests => 8;
 
-    $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
     $ENV{TESTAPP_CONFIG} = {
         name => 'TestApp',
         authentication => {
@@ -55,8 +52,6 @@
     ];
 }
 
-use SetupDB;
-
 use Catalyst::Test 'TestApp';
 
 # test user's admin access
@@ -82,6 +77,3 @@
     ok( my $res = request('http://localhost/user_login?username=nuffin&password=much&detach=is_admin_user'), 'request ok' );
     is( $res->content, 'failed', 'user is not an admin and a user' );
 }
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/06-auth-roles-column.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/06-auth-roles-column.t	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/06-auth-roles-column.t	2010-06-16 21:10:33 UTC (rev 13360)
@@ -23,9 +23,6 @@
 
     plan tests => 8;
 
-    $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
     $ENV{TESTAPP_CONFIG} = {
         name => 'TestApp',
         authentication => {
@@ -54,8 +51,6 @@
     ];
 }
 
-use SetupDB;
-
 use Catalyst::Test 'TestApp';
 
 # test user's admin access
@@ -81,6 +76,3 @@
     ok( my $res = request('http://localhost/user_login?username=joeuser&password=hackme&detach=is_admin_user'), 'request ok' );
     is( $res->content, 'failed', 'user is not an admin and a user' );
 }
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/07-authsessions-cached.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/07-authsessions-cached.t	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/07-authsessions-cached.t	2010-06-16 21:10:33 UTC (rev 13360)
@@ -21,7 +21,7 @@
         or plan skip_all =>
         "DBIx::Class is required for this test";
 
-    eval { require Catalyst::Plugin::Session; 
+    eval { require Catalyst::Plugin::Session;
            die unless $Catalyst::Plugin::Session::VERSION >= 0.02 }
         or plan skip_all =>
         "Catalyst::Plugin::Session >= 0.02 is required for this test";
@@ -33,8 +33,6 @@
 
     plan tests => 8;
 
-    $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
     $ENV{TESTAPP_CONFIG} = {
         name => 'TestApp',
         authentication => {
@@ -65,8 +63,6 @@
     ];
 }
 
-use SetupDB;
-
 use Test::WWW::Mechanize::Catalyst 'TestApp';
 my $m = Test::WWW::Mechanize::Catalyst->new;
 
@@ -93,6 +89,3 @@
     $m->get_ok( 'http://localhost/get_session_user', undef, 'request ok' );
     $m->content_is( '', "user's session deleted" );
 }
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/08-simpledb-auth-roles-relationship.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/08-simpledb-auth-roles-relationship.t	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/08-simpledb-auth-roles-relationship.t	2010-06-16 21:10:33 UTC (rev 13360)
@@ -23,9 +23,6 @@
 
     plan tests => 8;
 
-    $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
     $ENV{TESTAPP_CONFIG} = {
         name => 'TestApp',
         'Plugin::Authentication' => {
@@ -44,8 +41,6 @@
     ];
 }
 
-use SetupDB;
-
 use Catalyst::Test 'TestApp';
 
 # test user's admin access
@@ -71,6 +66,3 @@
     ok( my $res = request('http://localhost/user_login?username=nuffin&password=much&detach=is_admin_user'), 'request ok' );
     is( $res->content, 'failed', 'user is not an admin and a user' );
 }
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/09-simpledb-auth-roles-column.t
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/09-simpledb-auth-roles-column.t	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/09-simpledb-auth-roles-column.t	2010-06-16 21:10:33 UTC (rev 13360)
@@ -23,9 +23,6 @@
 
     plan tests => 8;
 
-    $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/auth.db" unless exists($ENV{TESTAPP_DB_FILE});
-
-
     $ENV{TESTAPP_CONFIG} = {
         name => 'TestApp',
         'Plugin::Authentication' => {
@@ -36,7 +33,7 @@
 				password_type => 'clear'
 			}
 		}
-        
+
     };
 
     $ENV{TESTAPP_PLUGINS} = [
@@ -46,8 +43,6 @@
     ];
 }
 
-use SetupDB;
-
 use Catalyst::Test 'TestApp';
 
 # test user's admin access
@@ -73,6 +68,3 @@
     ok( my $res = request('http://localhost/user_login?username=joeuser&password=hackme&detach=is_admin_user'), 'request ok' );
     is( $res->content, 'failed', 'user is not an admin and a user' );
 }
-
-# clean up
-unlink $ENV{TESTAPP_DB_FILE};

Deleted: Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/SetupDB.pm
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/SetupDB.pm	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/SetupDB.pm	2010-06-16 21:10:33 UTC (rev 13360)
@@ -1,37 +0,0 @@
-# create the database
-my $db_file = $ENV{TESTAPP_DB_FILE};
-unlink $db_file if -e $db_file;
-
-my $dbh = DBI->connect( "dbi:SQLite:$db_file" ) or die $DBI::errstr;
-my $sql = q{
-    CREATE TABLE user (
-        id       INTEGER PRIMARY KEY,
-        username TEXT,
-        email    TEXT,
-        password TEXT,
-        status   TEXT,
-        role_text TEXT,
-        session_data TEXT
-    );
-    CREATE TABLE role (
-        id   INTEGER PRIMARY KEY,
-        role TEXT
-    );
-    CREATE TABLE user_role (
-        id   INTEGER PRIMARY KEY,
-        user INTEGER,
-        roleid INTEGER
-    );
-
-    INSERT INTO user VALUES (1, 'joeuser', 'joeuser at nowhere.com', 'hackme', 'active', 'admin', NULL);
-    INSERT INTO user VALUES (2, 'spammer', 'bob at spamhaus.com', 'broken', 'disabled', NULL, NULL);
-    INSERT INTO user VALUES (3, 'jayk', 'j at cpants.org', 'letmein', 'active', NULL, NULL);
-    INSERT INTO user VALUES (4, 'nuffin', 'nada at mucho.net', 'much', 'registered', 'user admin', NULL);
-    INSERT INTO role VALUES (1, 'admin');
-    INSERT INTO role VALUES (2, 'user');
-    INSERT INTO user_role VALUES (1, 3, 1);
-    INSERT INTO user_role VALUES (2, 3, 2);
-    INSERT INTO user_role VALUES (3, 4, 2)
-};
-$dbh->do( $_ ) for split /;/, $sql;
-$dbh->disconnect;
\ No newline at end of file

Modified: Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/TestApp/Model/TestApp.pm
===================================================================
--- Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/TestApp/Model/TestApp.pm	2010-06-16 21:10:25 UTC (rev 13359)
+++ Catalyst-Authentication-Store-DBIx-Class/trunk/t/lib/TestApp/Model/TestApp.pm	2010-06-16 21:10:33 UTC (rev 13360)
@@ -3,17 +3,46 @@
 use base qw/Catalyst::Model::DBIC::Schema/;
 use strict;
 
+my @deployment_statements = split /;/, q{
+    CREATE TABLE user (
+        id       INTEGER PRIMARY KEY,
+        username TEXT,
+        email    TEXT,
+        password TEXT,
+        status   TEXT,
+        role_text TEXT,
+        session_data TEXT
+    );
+    CREATE TABLE role (
+        id   INTEGER PRIMARY KEY,
+        role TEXT
+    );
+    CREATE TABLE user_role (
+        id   INTEGER PRIMARY KEY,
+        user INTEGER,
+        roleid INTEGER
+    );
 
-our $db_file = $ENV{TESTAPP_DB_FILE};
+    INSERT INTO user VALUES (1, 'joeuser', 'joeuser at nowhere.com', 'hackme', 'active', 'admin', NULL);
+    INSERT INTO user VALUES (2, 'spammer', 'bob at spamhaus.com', 'broken', 'disabled', NULL, NULL);
+    INSERT INTO user VALUES (3, 'jayk', 'j at cpants.org', 'letmein', 'active', NULL, NULL);
+    INSERT INTO user VALUES (4, 'nuffin', 'nada at mucho.net', 'much', 'registered', 'user admin', NULL);
+    INSERT INTO role VALUES (1, 'admin');
+    INSERT INTO role VALUES (2, 'user');
+    INSERT INTO user_role VALUES (1, 3, 1);
+    INSERT INTO user_role VALUES (2, 3, 2);
+    INSERT INTO user_role VALUES (3, 4, 2)
+};
 
 __PACKAGE__->config(
     schema_class => 'TestApp::Schema',
-    connect_info => [ "dbi:SQLite:$db_file",
-              '',
-              '',
-              { AutoCommit => 1 },
-            ],
-
+    connect_info => [
+        "dbi:SQLite:dbname=:memory:",
+        '',
+        '',
+        { AutoCommit => 1 },
+        { on_connect_do => \@deployment_statements },
+    ],
 );
 
 # Load all of the classes




More information about the Catalyst-commits mailing list