[Rt-commit] r7146 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: lib/RT sbin

clkao at bestpractical.com clkao at bestpractical.com
Mon Mar 5 08:36:09 EST 2007


Author: clkao
Date: Mon Mar  5 08:36:08 2007
New Revision: 7146

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/regression/12-search.t
   rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in

Log:
Make RT::Test reset the database on import.

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Handle.pm	Mon Mar  5 08:36:08 2007
@@ -208,6 +208,11 @@
     $dbh->do("DROP DATABASE ". $db_name) or warn $DBI::errstr;
 }
 
+sub _yesno {
+    print "Proceed [y/N]:";
+    my $x = scalar(<STDIN>);
+    $x =~ /^y/i;
+}
 
 =head2 insert_acl
 
@@ -349,6 +354,7 @@
     $RT::Handle->Connect;
 
     #Put together a current user object so we can create a User object
+    require RT::CurrentUser;
     my $CurrentUser = new RT::CurrentUser();
 
     print "Checking for existing system user...";

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm	Mon Mar  5 08:36:08 2007
@@ -13,6 +13,7 @@
     print $config qq{
 Set( \$WebPort , $port);
 Set( \$WebBaseURL , "http://localhost:\$WebPort");
+Set( \$DatabaseName , "rt3test");
 1;
 };
     close $config;
@@ -22,7 +23,6 @@
     if (RT->Config->Get('DevelMode')) { require Module::Refresh; }
 
 };
-RT::Init;
 
 use RT::Interface::Web::Standalone;
 use Test::HTTP::Server::Simple;
@@ -32,6 +32,18 @@
 
 my @server;
 
+sub import {
+    require RT::Handle;
+    RT::Handle->drop_db(undef, { force => 1});
+    RT::Handle->create_db;
+
+    RT->ConnectToDatabase;
+    $RT::Handle->insert_schema($dbh);
+    $RT::Handle->insert_initial_data();
+    $RT::Handle->insert_data( $RT::EtcPath . "/initialdata" );
+    RT::Init;
+}
+
 sub started_ok {
     my $s = RT::Interface::Web::Standalone->new($port);
     push @server, $s;

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/regression/12-search.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/regression/12-search.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/regression/12-search.t	Mon Mar  5 08:36:08 2007
@@ -6,10 +6,8 @@
 use strict;
 use warnings;
 
-use Test::More tests => 44;
-use_ok('RT');
-RT::LoadConfig();
-RT::Init();
+use Test::More tests => 43;
+use RT::Test;
 
 # setup the queue
 

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/sbin/rt-setup-database.in	Mon Mar  5 08:36:08 2007
@@ -213,12 +213,6 @@
     return ($password);
 }
 
-sub _yesno {
-    print "Proceed [y/N]:";
-    my $x = scalar(<STDIN>);
-    $x =~ /^y/i;
-}
-
 =head2 get_system_dsn
 
 Returns a DSN suitable for database creates and drops


More information about the Rt-commit mailing list