diff --git a/Web/lib/MJB/Web/Test.pm b/Web/lib/MJB/Web/Test.pm index cf8c111..a93008d 100644 --- a/Web/lib/MJB/Web/Test.pm +++ b/Web/lib/MJB/Web/Test.pm @@ -9,6 +9,8 @@ use Mojo::File; push our @ISA, qw( Exporter ); push our @EXPORT, qw( $run_code ); +our $pgsql; + sub import { shift->export_to_level(1); my $target = caller; @@ -21,14 +23,16 @@ sub import { Test::Mojo::MJB->import::into($target); } -our $pgsql = Test::Postgresql58->new() - or BAILOUT( "PSQL Error: " . $Test::Postgresql58::errstr ); +sub enable_testing_database { + $pgsql = Test::Postgresql58->new() + or BAILOUT( "PSQL Error: " . $Test::Postgresql58::errstr ); -load_psql_file("../DB/etc/schema.sql"); + load_psql_file("../DB/etc/schema.sql"); -$ENV{MJB_TESTMODE} = 1; -$ENV{MJB_DSN} = $pgsql->dsn; -$ENV{MJB_TESTMODE_TEMPDIR} = Mojo::File::tempdir->to_string; + $ENV{MJB_TESTMODE} = 1; + $ENV{MJB_DSN} = $pgsql->dsn; + $ENV{MJB_TESTMODE_TEMPDIR} = Mojo::File::tempdir->to_string; +} sub load_psql_file { my ( $file ) = @_;