Refactor tests a little bit.
Amiri Barksdale at Home [Fri, 24 Dec 2010 04:29:21 +0000 (20:29 -0800)]
21 files changed:
Makefile.PL
t/00use.t
t/01load.t
t/02view_def.t
t/03insert.t
t/04no_sequence_defined.t
t/lib/Cafe/Result/Sumatra.pm [deleted file]
t/lib/CafeInsertion.pm [moved from t/lib/Cafe.pm with 92% similarity]
t/lib/CafeInsertion/Result/Coffee.pm [moved from t/lib/Cafe/Result/Coffee.pm with 91% similarity]
t/lib/CafeInsertion/Result/Sugar.pm [moved from t/lib/Cafe/Result/Sugar.pm with 89% similarity]
t/lib/CafeInsertion/Result/Sumatra.pm [new file with mode: 0644]
t/lib/LoadTest.pm [moved from t/lib/MTITest.pm with 94% similarity]
t/lib/LoadTest/Result/Bar.pm [moved from t/lib/MTITest/Result/Bar.pm with 60% similarity]
t/lib/LoadTest/Result/Foo.pm [moved from t/lib/MTITest/Result/Foo.pm with 88% similarity]
t/lib/LoadTest/Result/JustATable.pm [moved from t/lib/MTITest/Result/JustATable.pm with 83% similarity]
t/lib/LoadTest/Result/Mixin.pm [moved from t/lib/MTITest/Result/Mixin.pm with 89% similarity]
t/lib/NoSequence/Result/Mesclun.pm [deleted file]
t/lib/NoSequenceSalad.pm [moved from t/lib/NoSequence.pm with 92% similarity]
t/lib/NoSequenceSalad/Result/Dressing.pm [moved from t/lib/NoSequence/Result/Dressing.pm with 87% similarity]
t/lib/NoSequenceSalad/Result/Mesclun.pm [new file with mode: 0644]
t/lib/NoSequenceSalad/Result/Salad.pm [moved from t/lib/NoSequence/Result/Salad.pm with 90% similarity]

index e6a548a..594a11b 100644 (file)
@@ -32,5 +32,7 @@ requires 'namespace::autoclean';
 requires 'parent';
 requires 'signatures';
 
+test_requires 'Module::Find';
+
 auto_install;
 WriteAll;
index 5abfcf2..66ee904 100644 (file)
--- a/t/00use.t
+++ b/t/00use.t
@@ -2,5 +2,16 @@ use strict;
 use warnings;
 use lib 't/lib';
 use Test::More qw(no_plan);
+use Module::Find;
 
-BEGIN { use_ok $_ for qw/MTITest NoSequence Cafe/; }
+BEGIN {
+    use_ok 'DBIx::Class::ResultSource::MultipleTableInheritance';
+
+    for (qw/LoadTest NoSequenceSalad CafeInsertion/) {
+        use_ok $_;
+        my @modules = findallmod $_;
+        for my $result_class (@modules) {
+            use_ok $result_class;
+        }
+    }
+}
index 664c2c5..e5163bc 100644 (file)
@@ -2,46 +2,35 @@ use strict;
 use warnings;
 use lib 't/lib';
 use Test::More qw(no_plan);
+use LoadTest;
 
-BEGIN { use_ok 'MTITest'; }
+BEGIN {
+    $ENV{DBIC_TRACE} = 0;
+}
+my $raw_foo = LoadTest->source('Raw::Foo');
 
-my $raw_foo = MTITest->source('Raw::Foo');
+is_deeply( [ $raw_foo->columns ], [qw(id a)],
+    'Columns for raw foo ok: id a' );
 
-is_deeply(
-  [ $raw_foo->columns ],
-  [ qw(id a) ],
-  'Columns for raw foo ok: id a'
-);
-
-my $raw_bar = MTITest->source('Raw::Bar');
+my $raw_bar = LoadTest->source('Raw::Bar');
 
-is_deeply(
-  [ $raw_bar->columns ],
-  [ qw(id b) ],
-  'Columns for raw bar ok: id b'
-);
+is_deeply( [ $raw_bar->columns ], [qw(id b)],
+    'Columns for raw bar ok: id b' );
 
-ok($raw_bar->has_relationship('parent'), 'parent rel exists');
+ok( $raw_bar->has_relationship('parent'), 'parent rel exists' );
 
 my $parent_info = $raw_bar->relationship_info('parent');
 
-is(
-  $parent_info->{source}, 'Raw::Foo',
-  'parent rel points to raw parent'
-);
-
-my $foo = MTITest->source('Foo');
-my $bar = MTITest->source('Bar');
+is( $parent_info->{source}, 'Raw::Foo', 'parent rel points to raw parent' );
 
-is_deeply(
-  [ $foo->columns ],
-  [ qw(id a) ],
-  'Columns for mti foo are still the same: id a'
-);
+my $foo = LoadTest->source('Foo');
+my $bar = LoadTest->source('Bar');
 
+is_deeply( [ $foo->columns ],
+    [qw(id a)], 'Columns for mti foo are still the same: id a' );
 
 is_deeply(
-  [ $bar->columns ],
-  [ qw(id a words b) ],
-  'Columns for mti bar now contain those of foo and the mixin: id a words b'
+    [ $bar->columns ],
+    [qw(id a words b)],
+    'Columns for mti bar now contain those of foo and the mixin: id a words b'
 );
index 3cda01d..f188e18 100644 (file)
@@ -4,10 +4,9 @@ use lib 't/lib';
 use File::Temp;
 use Test::More qw(no_plan);
 use Test::Exception;
-use Devel::Dwarn;
+use LoadTest;
 
 BEGIN {
-    use_ok 'MTITest';
     $ENV{DBIC_TRACE} = 0;
 }
 
@@ -19,18 +18,16 @@ Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
 ( NOTE: This test drops and creates some tables.')
 EOM
 
-dies_ok { MTITest->source('Foo')->view_definition }
+dies_ok { LoadTest->source('Foo')->view_definition }
 "Can't generate view def without connected schema";
 
-my $schema = MTITest->connect( $dsn, $user, $pass );
+my $schema = LoadTest->connect( $dsn, $user, $pass );
 
 my $dir = "t/sql";    # tempdir(CLEANUP => 0);
 
-$schema->storage->dbh->{Warn} = 0;
 lives_ok { $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ) }
 "It's OK to create_ddl_dir";
 lives_ok {
-    $schema->deploy(
-        { add_drop_table => 1, add_drop_view => 1, } );
+    $schema->deploy( { add_drop_table => 1, add_drop_view => 1, } );
 }
 "It's also OK to deploy the schema";
index b82ecbc..add074e 100644 (file)
@@ -3,12 +3,12 @@ use warnings;
 use lib 't/lib';
 use Test::More qw(no_plan);
 use Test::Exception;
-use Devel::Dwarn;
+use CafeInsertion;
 
 BEGIN {
-    use_ok 'Cafe';
     $ENV{DBIC_TRACE} = 0;
 }
+
 my ( $dsn, $user, $pass )
     = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
 plan skip_all => <<'EOM' unless $dsn && $user;
@@ -16,8 +16,7 @@ Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
 ( NOTE: This test drops and creates some tables.')
 EOM
 
-my $schema = Cafe->connect( $dsn, $user, $pass );
-$schema->storage->dbh->{Warn} = 0;
+my $schema = CafeInsertion->connect( $dsn, $user, $pass );
 $schema->storage->ensure_connected;
 $schema->storage->_use_insert_returning(0);
 
index d210d69..04dc763 100644 (file)
@@ -3,13 +3,11 @@ use warnings;
 use lib 't/lib';
 use Test::More qw(no_plan);
 use Test::Exception;
-use Devel::Dwarn;
+use NoSequenceSalad;
 
 BEGIN {
-    use_ok 'NoSequence';
-    $ENV{DBIC_TRACE} = 0;
+  $ENV{DBIC_TRACE} = 0;
 }
-
 my ( $dsn, $user, $pass )
     = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
 
@@ -18,8 +16,7 @@ Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
 ( NOTE: This test drops and creates some tables.')
 EOM
 
-my $schema = NoSequence->connect( $dsn, $user, $pass );
-$schema->storage->dbh->{Warn} = 0;
+my $schema = NoSequenceSalad->connect( $dsn, $user, $pass );
 $schema->storage->ensure_connected;
 $schema->storage->_use_insert_returning(0);
 
diff --git a/t/lib/Cafe/Result/Sumatra.pm b/t/lib/Cafe/Result/Sumatra.pm
deleted file mode 100644 (file)
index 40a693e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package Cafe::Result::Sumatra;
-
-use strict;
-use warnings;
-use parent 'Cafe::Result::Coffee';
-
-require Cafe::Result::Sugar;
-
-__PACKAGE__->table('sumatra');
-__PACKAGE__->result_source_instance->add_additional_parent(
-    Cafe::Result::Sugar->result_source_instance );
-__PACKAGE__->add_columns( "aroma", { data_type => "text" } );
-
-#__PACKAGE__->has_many( 'coffees', 'Cafe::Result::Coffee',
-#{ 'foreign.id' => 'self.id' } );
-
-1;
similarity index 92%
rename from t/lib/Cafe.pm
rename to t/lib/CafeInsertion.pm
index 4449f6e..73ff34f 100644 (file)
@@ -1,4 +1,4 @@
-package Cafe;
+package CafeInsertion;
 
 use strict;
 use warnings;
similarity index 91%
rename from t/lib/Cafe/Result/Coffee.pm
rename to t/lib/CafeInsertion/Result/Coffee.pm
index 9468ddb..4b4fdce 100644 (file)
@@ -1,4 +1,4 @@
-package Cafe::Result::Coffee;
+package CafeInsertion::Result::Coffee;
 
 use strict;
 use warnings;
similarity index 89%
rename from t/lib/Cafe/Result/Sugar.pm
rename to t/lib/CafeInsertion/Result/Sugar.pm
index 9db81f3..e2cf4b1 100644 (file)
@@ -1,4 +1,4 @@
-package Cafe::Result::Sugar;
+package CafeInsertion::Result::Sugar;
 
 use strict;
 use warnings;
diff --git a/t/lib/CafeInsertion/Result/Sumatra.pm b/t/lib/CafeInsertion/Result/Sumatra.pm
new file mode 100644 (file)
index 0000000..17e4606
--- /dev/null
@@ -0,0 +1,17 @@
+package CafeInsertion::Result::Sumatra;
+
+use strict;
+use warnings;
+use parent 'CafeInsertion::Result::Coffee';
+
+require CafeInsertion::Result::Sugar;
+
+__PACKAGE__->table('sumatra');
+__PACKAGE__->result_source_instance->add_additional_parent(
+    CafeInsertion::Result::Sugar->result_source_instance );
+__PACKAGE__->add_columns( "aroma", { data_type => "text" } );
+
+#__PACKAGE__->has_many( 'coffees', 'CafeInsertion::Result::Coffee',
+#{ 'foreign.id' => 'self.id' } );
+
+1;
similarity index 94%
rename from t/lib/MTITest.pm
rename to t/lib/LoadTest.pm
index 3b1593a..012b3e1 100644 (file)
@@ -1,4 +1,4 @@
-package MTITest;
+package LoadTest;
 
 use strict;
 use warnings;
similarity index 60%
rename from t/lib/MTITest/Result/Bar.pm
rename to t/lib/LoadTest/Result/Bar.pm
index b02325c..0712ac9 100644 (file)
@@ -1,15 +1,15 @@
-package MTITest::Result::Bar;
+package LoadTest::Result::Bar;
 
 use strict;
 use warnings;
-use parent qw(MTITest::Result::Foo);
+use parent qw(LoadTest::Result::Foo);
 
-require MTITest::Result::Mixin;
+require LoadTest::Result::Mixin;
 
 __PACKAGE__->table('bar');
 
 __PACKAGE__->result_source_instance->add_additional_parent(
-  MTITest::Result::Mixin->result_source_instance
+  LoadTest::Result::Mixin->result_source_instance
 );
 
 __PACKAGE__->add_columns(
@@ -18,13 +18,13 @@ __PACKAGE__->add_columns(
 
 __PACKAGE__->belongs_to(
   'b_thang',
-  'MTITest::Result::JustATable',
+  'LoadTest::Result::JustATable',
   { 'foreign.id' => 'self.b' },
 );
 
 __PACKAGE__->has_many(
   'foos',
-  'MTITest::Result::Foo',
+  'LoadTest::Result::Foo',
   { 'foreign.a' => 'self.id' }
 );
 
similarity index 88%
rename from t/lib/MTITest/Result/Foo.pm
rename to t/lib/LoadTest/Result/Foo.pm
index d8b8e1b..a14a209 100644 (file)
@@ -1,4 +1,4 @@
-package MTITest::Result::Foo;
+package LoadTest::Result::Foo;
 
 use strict;
 use warnings;
@@ -18,7 +18,7 @@ __PACKAGE__->set_primary_key('id');
 
 __PACKAGE__->belongs_to(
   'bar',
-  'MTITest::Result::Bar',
+  'LoadTest::Result::Bar',
   { 'foreign.id' => 'self.a' }
 );
 
similarity index 83%
rename from t/lib/MTITest/Result/JustATable.pm
rename to t/lib/LoadTest/Result/JustATable.pm
index 08c602f..a73838c 100644 (file)
@@ -1,4 +1,4 @@
-package MTITest::Result::JustATable;
+package LoadTest::Result::JustATable;
 
 use base qw(DBIx::Class::Core);
 
@@ -13,7 +13,7 @@ __PACKAGE__->set_primary_key('id');
 
 __PACKAGE__->has_many(
   'bars',
-  'MTITest::Result::Bar',
+  'LoadTest::Result::Bar',
   { 'foreign.b' => 'self.id' }
 );
 
similarity index 89%
rename from t/lib/MTITest/Result/Mixin.pm
rename to t/lib/LoadTest/Result/Mixin.pm
index e6c1124..eac1158 100644 (file)
@@ -1,4 +1,4 @@
-package MTITest::Result::Mixin;
+package LoadTest::Result::Mixin;
 
 use strict;
 use warnings;
diff --git a/t/lib/NoSequence/Result/Mesclun.pm b/t/lib/NoSequence/Result/Mesclun.pm
deleted file mode 100644 (file)
index 68bbf18..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-package NoSequence::Result::Mesclun;
-
-use strict;
-use warnings;
-use parent 'NoSequence::Result::Salad';
-
-require NoSequence::Result::Dressing;
-
-__PACKAGE__->table('mesclun');
-__PACKAGE__->result_source_instance->add_additional_parent(
-    NoSequence::Result::Dressing->result_source_instance );
-__PACKAGE__->add_columns( "spiciness", { data_type => "integer" } );
-
-1;
similarity index 92%
rename from t/lib/NoSequence.pm
rename to t/lib/NoSequenceSalad.pm
index 1b59318..012354c 100644 (file)
@@ -1,4 +1,4 @@
-package NoSequence;
+package NoSequenceSalad;
 
 use strict;
 use warnings;
similarity index 87%
rename from t/lib/NoSequence/Result/Dressing.pm
rename to t/lib/NoSequenceSalad/Result/Dressing.pm
index a57d225..77b3d61 100644 (file)
@@ -1,4 +1,4 @@
-package NoSequence::Result::Dressing;
+package NoSequenceSalad::Result::Dressing;
 
 use strict;
 use warnings;
diff --git a/t/lib/NoSequenceSalad/Result/Mesclun.pm b/t/lib/NoSequenceSalad/Result/Mesclun.pm
new file mode 100644 (file)
index 0000000..6e35e3a
--- /dev/null
@@ -0,0 +1,14 @@
+package NoSequenceSalad::Result::Mesclun;
+
+use strict;
+use warnings;
+use parent 'NoSequenceSalad::Result::Salad';
+
+require NoSequenceSalad::Result::Dressing;
+
+__PACKAGE__->table('mesclun');
+__PACKAGE__->result_source_instance->add_additional_parent(
+    NoSequenceSalad::Result::Dressing->result_source_instance );
+__PACKAGE__->add_columns( "spiciness", { data_type => "integer" } );
+
+1;
similarity index 90%
rename from t/lib/NoSequence/Result/Salad.pm
rename to t/lib/NoSequenceSalad/Result/Salad.pm
index 7249d18..9dcd913 100644 (file)
@@ -1,4 +1,4 @@
-package NoSequence::Result::Salad;
+package NoSequenceSalad::Result::Salad;
 
 use strict;
 use warnings;