From: Johannes Plunien Date: Wed, 24 Sep 2008 21:24:27 +0000 (+0200) Subject: default sqlite storage ":memory:", possible to switch back to file storage using... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=481df957ba11d4609e981e0a89e6175547171d24;p=dbsrgits%2FDBIx-Class-Historic.git default sqlite storage ":memory:", possible to switch back to file storage using ->init_schema( sqlite_use_file => 1 ) --- diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index aea28e1..617d6c5 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -51,12 +51,16 @@ sub has_custom_dsn { } sub _sqlite_dbfilename { - return "t/var/DBIxClass.db"; + my $self = shift; + my %args = @_; + return "t/var/DBIxClass.db" if $args{sqlite_use_file} or $ENV{"DBICTEST_SQLITE_USE_FILE"}; + return ":memory:"; } sub _database { my $self = shift; - my $db_file = $self->_sqlite_dbfilename; + my %args = @_; + my $db_file = $self->_sqlite_dbfilename(%args); unlink($db_file) if -e $db_file; unlink($db_file . "-journal") if -e $db_file . "-journal"; @@ -76,10 +80,10 @@ sub init_schema { my %args = @_; my $schema; - + if ($args{compose_connection}) { $schema = DBICTest::Schema->compose_connection( - 'DBICTest', $self->_database + 'DBICTest', $self->_database(%args) ); } else { $schema = DBICTest::Schema->compose_namespace('DBICTest'); @@ -88,7 +92,7 @@ sub init_schema { $schema->storage_type($args{storage_type}); } if ( !$args{no_connect} ) { - $schema = $schema->connect($self->_database); + $schema = $schema->connect($self->_database(%args)); $schema->storage->on_connect_do(['PRAGMA synchronous = OFF']) unless $self->has_custom_dsn; }