From f406dd7b884d6b37922043a8c7ed79e75cfbe7c8 Mon Sep 17 00:00:00 2001 From: Manager Bot Date: Mon, 5 Dec 2022 16:02:25 +0000 Subject: [PATCH] Load DB explictly. --- Web/lib/MJB/Web/Test.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 ) = @_;