Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

JCOM::DB::DBICWrapper dies straight aways when a resultset is not found

  • Loading branch information...
commit 706521a14bbbfd3d2bc319f20cb025a11fb94380 1 parent 1ccb4fc
@jeteve authored
View
3  JCOM-BM/Build.PL
@@ -10,9 +10,10 @@ my $builder = Module::Build->new(
build_requires => {
'Test::More' => 0,
'Moose' => 0,
- 'DBIx::Class::Schema::Loader' => 0,
+ 'DBIx::Class::Schema::Loader' => 0,
'Module::Pluggable::Object' => 0,
'DBIx::Class' => 0,
+ 'Test::Fatal' => 0.008
},
add_to_cleanup => [ 'JCOM-BM-*' ],
create_makefile_pl => 'traditional',
View
7 JCOM-BM/lib/JCOM/BM/DBICWrapper.pm
@@ -40,7 +40,8 @@ sub _build__jcom_dbic_fact_classes{
=head2 dbic_factory
-Returns a new instance of L<JCOM::BM::Factory> that wraps around the given DBIC ResultSet name.
+Returns a new instance of L<JCOM::BM::Factory> that wraps around the given DBIC ResultSet name
+if such a resultset exists. Dies otherwise.
usage:
@@ -64,7 +65,9 @@ sub dbic_factory{
## Ok, $class_name is now there
## Note that the factory will built its own resultset from this model and the name
- return $class_name->new({ bm => $self , name => $name });
+ my $instance = $class_name->new({ bm => $self , name => $name });
+ my $dbic_rs = $instance->dbic_rs();
+ return $instance;
}
1;
View
6 JCOM-BM/t/01-dbic_wrapper.t
@@ -1,6 +1,7 @@
#!perl -T
use Test::More;
+use Test::Fatal qw/dies_ok lives_ok/;
# use File::Temp;
use DBI;
use DBD::SQLite;
@@ -146,4 +147,9 @@ cmp_ok( $pf2->search()->count() , '==' , 2 , "Now two products in the active res
cmp_ok( $bm->dbic_factory('ColouredProduct')->count() , '==' , 2 , 'Now two coloured product');
}
+## Test a non existing factory
+{
+ dies_ok { $bm->dbic_factory('BoudinBlanc') } "No boudin blanc factory";
+}
+
done_testing();
Please sign in to comment.
Something went wrong with that request. Please try again.