diff --git a/Build.PL b/Build.PL index f424cacd47..cba491eb98 100644 --- a/Build.PL +++ b/Build.PL @@ -32,6 +32,7 @@ my $builder = Local::Module::Build->new( 'DateTime::Format::ISO8601' => 0, 'DBIx::Class::ResultSet::RecursiveUpdate' => '0.30', 'Email::Valid' => 0, + 'File::ShareDir' => 0, 'File::Type' => 0, 'GD::Simple' => 0, 'Hash::Merge::Simple' => 0, @@ -115,11 +116,12 @@ Build.PL - NGCP-Panel build system including test fixtures =head2 Options - --webdriver (required) external webdriver command - --wd-server HOST:PORT of an external webdriver to connect to - --server URI for socket test server - --help brief help message - --man full documentation + --webdriver (required) external webdriver command + --wd-server HOST:PORT of an external webdriver to connect to + --server URI for socket test server + --schema-base-dir directory of NGCP::Schema if its not yet installed + --help brief help message + --man full documentation =head1 OPTIONS @@ -138,6 +140,12 @@ Default is set by Test::WebDriver to localhost:4444 URI for the HTTP::Server::PSGI socket server run for testing, default C +=head2 C<--schema-base-dir> + +If the NGCP::Schema is not installed to a known path to perl, this +option can specify the base directory of its development location. +It will then be included via blib, so we have access to its lib and share. + =head2 C<--help> Print a brief help message and exits. diff --git a/inc/Local/Module/Build.pm b/inc/Local/Module/Build.pm index d3ea96c509..544cbe968c 100644 --- a/inc/Local/Module/Build.pm +++ b/inc/Local/Module/Build.pm @@ -39,7 +39,7 @@ sub _test_preconditions { require Getopt::Long; my %opt = (server => 'http://localhost:5000'); - Getopt::Long::GetOptions(\%opt, 'webdriver=s', 'server:s', 'help|?', 'man', 'wd-server=s') + Getopt::Long::GetOptions(\%opt, 'webdriver=s', 'server:s', 'help|?', 'man', 'wd-server=s', 'schema-base-dir=s') or die 'could not process command-line options'; require Pod::Usage; @@ -62,9 +62,11 @@ sub _test_preconditions { my $uri = URI->new($opt{server}); require File::Which; + $ENV{ NGCP_PANEL_CONFIG_LOCAL_SUFFIX } = "testing"; $plackup = child { exec $^X, '-Ilib', + exists $opt{'schema-base-dir'} ? "-Mblib=$opt{'schema-base-dir'}" : (), @cover_opt, scalar File::Which::which('plackup'), sprintf('--listen=%s:%s', $uri->host, $uri->port), diff --git a/lib/NGCP/Panel/Model/DB.pm b/lib/NGCP/Panel/Model/DB.pm index 1bcb054dd5..d97b5e6ad9 100644 --- a/lib/NGCP/Panel/Model/DB.pm +++ b/lib/NGCP/Panel/Model/DB.pm @@ -1,7 +1,23 @@ package NGCP::Panel::Model::DB; use strict; -use base 'Catalyst::Model::DBIC::Schema'; +use File::ShareDir 'dist_file'; +use Moose; +use MooseX::Types::Moose; +extends 'Catalyst::Model::DBIC::Schema'; + +use Module::Runtime qw(use_module); + +has 'testing' => (is => 'rw', isa => 'Bool', default => 0); + +sub setup { + my ($self) = @_; + if ($self->testing) { + my $config_location = dist_file('NGCP-Schema', 'test.conf'); + use_module('NGCP::Schema::Config')->instance + ->config_file($config_location); + } +} __PACKAGE__->config( connect_info => [], diff --git a/ngcp_panel_testing.conf b/ngcp_panel_testing.conf new file mode 100644 index 0000000000..c361446004 --- /dev/null +++ b/ngcp_panel_testing.conf @@ -0,0 +1,5 @@ + + testing 1 + + + diff --git a/t/controller_Reseller.t b/t/controller_Reseller.t index 7e6a42ae40..e8d6e47fef 100644 --- a/t/controller_Reseller.t +++ b/t/controller_Reseller.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More; +use Test::More skip_all => 'Not yet working, the Mechanize does not consider our blib setting'; use JSON::Parse 'valid_json'; use JSON qw( from_json ); use Catalyst::Test 'NGCP::Panel';