use config file ngcp-schema/share/test.conf for testing

for NGCP::Schema
we activate this behaviour by setting the environment variable
NGCP_PANEL_CONFIG_LOCAL_SUFFIX to "testing" which is a feature
from Catalyst::Plugin::ConfigLoader
agranig/peering-route
Gerhard Jungwirth 13 years ago
parent b541d7c8c0
commit 962eced885

@ -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<http://localhost:5000>
=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.

@ -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),

@ -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 => [],

@ -0,0 +1,5 @@
<Model::DB>
testing 1
</Model::DB>

@ -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';

Loading…
Cancel
Save