From: Amiri Barksdale at Home Date: Fri, 24 Dec 2010 02:59:32 +0000 (-0800) Subject: Add new test for basic sanity X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=32098147b1ca9f76579541b0dd5e5df03e637162;p=dbsrgits%2FDBIx-Class-ResultSource-MultipleTableInheritance.git Add new test for basic sanity --- diff --git a/Makefile.PL b/Makefile.PL index 2419d3f..e6a548a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -3,13 +3,26 @@ use warnings; use inc::Module::Install; if ($Module::Install::AUTHOR) { - system('pod2text lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm > README'); - system('pod2html lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm > README.html'); + system( + 'pod2text lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm > README' + ); + system( + 'pod2html lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm > README.html' + ); } name 'DBIx-Class-ResultSource-MultipleTableInheritance'; all_from 'lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm'; +configure_requires 'DBIx::Class' => '0.08124'; +require DBIx::Class::Optional::Dependencies; + +my $deploy_deps = DBIx::Class::Optional::Dependencies->req_list_for('deploy'); + +for ( keys %$deploy_deps ) { + requires $_ => $deploy_deps->{$_}; +} + requires 'Carp::Clan'; requires 'DBIx::Class'; requires 'Method::Signatures::Simple'; diff --git a/t/00use.t b/t/00use.t new file mode 100644 index 0000000..5abfcf2 --- /dev/null +++ b/t/00use.t @@ -0,0 +1,6 @@ +use strict; +use warnings; +use lib 't/lib'; +use Test::More qw(no_plan); + +BEGIN { use_ok $_ for qw/MTITest NoSequence Cafe/; } diff --git a/t/02view_def.t b/t/02view_def.t index 7dffd5c..3cda01d 100644 --- a/t/02view_def.t +++ b/t/02view_def.t @@ -11,13 +11,26 @@ BEGIN { $ENV{DBIC_TRACE} = 0; } +my ( $dsn, $user, $pass ) + = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ }; + +plan skip_all => <<'EOM' unless $dsn && $user; +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 } "Can't generate view def without connected schema"; -my $schema = MTITest->connect( 'dbi:Pg:dbname=test', 'postgres', '' ); +my $schema = MTITest->connect( $dsn, $user, $pass ); my $dir = "t/sql"; # tempdir(CLEANUP => 0); -#$schema->storage->dbh->{Warn} = 0; -$schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ); -$schema->deploy( { add_drop_table => 1, add_drop_view => 1} ); +$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, } ); +} +"It's also OK to deploy the schema"; diff --git a/t/03insert.t b/t/03insert.t index d237f4a..b82ecbc 100644 --- a/t/03insert.t +++ b/t/03insert.t @@ -9,8 +9,14 @@ BEGIN { use_ok 'Cafe'; $ENV{DBIC_TRACE} = 0; } - -my $schema = Cafe->connect( 'dbi:Pg:dbname=test', 'postgres', '' ); +my ( $dsn, $user, $pass ) + = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ }; +plan skip_all => <<'EOM' unless $dsn && $user; +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; $schema->storage->ensure_connected; $schema->storage->_use_insert_returning(0); @@ -38,4 +44,3 @@ lives_ok { } "I can do it for the other view, too"; - diff --git a/t/04no_sequence_defined.t b/t/04no_sequence_defined.t index ce30122..d210d69 100644 --- a/t/04no_sequence_defined.t +++ b/t/04no_sequence_defined.t @@ -10,7 +10,15 @@ BEGIN { $ENV{DBIC_TRACE} = 0; } -my $schema = NoSequence->connect( 'dbi:Pg:dbname=test', 'postgres', '' ); +my ( $dsn, $user, $pass ) + = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ }; + +plan skip_all => <<'EOM' unless $dsn && $user; +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; $schema->storage->ensure_connected; $schema->storage->_use_insert_returning(0); @@ -38,4 +46,3 @@ lives_ok { } "I can do it for the other view, too"; -