From: Peter Rabbitson Date: Tue, 3 Mar 2009 09:30:15 +0000 (+0000) Subject: Rewrite t/54taint.t to properly test load_namespaces() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=91b0ad0b21a3c167f5ae0ac240322de8b6601058;p=dbsrgits%2FDBIx-Class-Historic.git Rewrite t/54taint.t to properly test load_namespaces() --- diff --git a/t/54taint.t b/t/54taint.t index 69f69ef..f54ed93 100644 --- a/t/54taint.t +++ b/t/54taint.t @@ -5,29 +5,52 @@ use strict; use warnings; -our @plan; +use Test::More; BEGIN { eval "require Module::Find;"; - @plan = $@ ? ( skip_all => 'Could not load Module::Find' ) - : ( tests => 2 ); + if ($@) { + plan skip_all => 'Could not load Module::Find'; + exit; + } + else { + plan tests => 7; + } } -package DBICTest::Plain; +package DBICTest::Taint::Classes; -# Use the Plain test class namespace to avoid the need for a -# new test infrastructure. If invalid classes will be introduced to -# 't/lib/DBICTest/Plain/' someday, this has to be reworked. +use Test::More; +use Test::Exception; use lib qw(t/lib); +use base qw/DBIx::Class::Schema/; + +lives_ok (sub { + __PACKAGE__->load_classes(qw/Manual/); + ok( __PACKAGE__->source('Manual'), 'The Classes::Manual source has been registered' ); + __PACKAGE__->_unregister_source (qw/Manual/); +}, 'Loading classes with explicit load_classes worked in taint mode' ); + +lives_ok (sub { + __PACKAGE__->load_classes(); + ok( __PACKAGE__->source('Auto'), 'The Classes::Auto source has been registered' ); + ok( __PACKAGE__->source('Auto'), 'The Classes::Manual source has been re-registered' ); +}, 'Loading classes with Module::Find/load_classes worked in taint mode' ); + -use Test::More @plan; +package DBICTest::Taint::Namespaces; +use Test::More; +use Test::Exception; + +use lib qw(t/lib); use base qw/DBIx::Class::Schema/; -eval{ __PACKAGE__->load_classes() }; -cmp_ok( $@, 'eq', '', - 'Loading classes with Module::Find worked in taint mode' ); -ok( __PACKAGE__->source('Test'), 'The Plain::Test source has been registered' ); +lives_ok (sub { + __PACKAGE__->load_namespaces(); + ok( __PACKAGE__->source('Test'), 'The Namespaces::Test source has been registered' ); +}, 'Loading classes with Module::Find/load_namespaces worked in taint mode' ); + 1; diff --git a/t/lib/DBICTest/Taint/Classes/Auto.pm b/t/lib/DBICTest/Taint/Classes/Auto.pm new file mode 100644 index 0000000..9a30c1a --- /dev/null +++ b/t/lib/DBICTest/Taint/Classes/Auto.pm @@ -0,0 +1,7 @@ +package # hide from PAUSE + DBICTest::Taint::Classes::Auto; + +use base 'DBIx::Class::Core'; +__PACKAGE__->table('test'); + +1; diff --git a/t/lib/DBICTest/Taint/Classes/Manual.pm b/t/lib/DBICTest/Taint/Classes/Manual.pm new file mode 100644 index 0000000..5d2109b --- /dev/null +++ b/t/lib/DBICTest/Taint/Classes/Manual.pm @@ -0,0 +1,7 @@ +package # hide from PAUSE + DBICTest::Taint::Classes::Manual; + +use base 'DBIx::Class::Core'; +__PACKAGE__->table('test'); + +1; diff --git a/t/lib/DBICTest/Taint/Namespaces/Result/Test.pm b/t/lib/DBICTest/Taint/Namespaces/Result/Test.pm new file mode 100644 index 0000000..7d57bb5 --- /dev/null +++ b/t/lib/DBICTest/Taint/Namespaces/Result/Test.pm @@ -0,0 +1,7 @@ +package # hide from PAUSE + DBICTest::Taint::Namespaces::Result::Test; + +use base 'DBIx::Class::Core'; +__PACKAGE__->table('test'); + +1;