From: zby Date: Mon, 2 Feb 2009 13:49:35 +0000 (+0000) Subject: a few tests X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=dd98344ab0d8b1c141f7090ffa576ff2f25b9f51;p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate a few tests --- diff --git a/t/lib/RunTests.pm b/t/lib/RunTests.pm index 2036de0..cce65e0 100644 --- a/t/lib/RunTests.pm +++ b/t/lib/RunTests.pm @@ -5,8 +5,11 @@ use Exporter 'import'; # gives you Exporter's import() method directly use strict; use Test::More; + sub run_tests{ my $schema = shift; + + plan tests => 24; my $dvd_rs = $schema->resultset( 'Dvd' ); my $user_rs = $schema->resultset( 'User' ); @@ -23,19 +26,18 @@ sub run_tests{ id => undef, name => 'Test name 2', viewings => [ { user_id => $owner->id } ], - owner => { id => $owner->id }, + owner => { id => $another_owner->id }, }; my $new_dvd = $dvd_rs->recursive_update( $updates ); # my $new_dvd = $dvd_rs->create( $updates ); - ok ( $new_dvd->isa( 'DBSchema::Result::Dvd' ), 'Dvd created' ); is ( $dvd_rs->count, $initial_dvd_count + 1, 'Dvd created' ); is ( $schema->resultset( 'User' )->count, $initial_user_count, "No new user created" ); is ( $new_dvd->name, 'Test name 2', 'Dvd name set' ); - is ( $new_dvd->owner->id, $owner->id, 'Owner set' ); + is ( $new_dvd->owner->id, $another_owner->id, 'Owner set' ); is ( $new_dvd->viewings->count, 1, 'Viewing created' ); -; + # creating new records my $updates = { id => undef, @@ -112,6 +114,8 @@ sub run_tests{ }; my $user = $user_rs->recursive_update( $updates ); + is ( $schema->resultset( 'User' )->count, $initial_user_count + 2, "New user created" ); + is ( $dvd_rs->count, $initial_dvd_count + 4, 'Dvds created' ); my %owned_dvds = map { $_->name => $_ } $user->owned_dvds; is( scalar keys %owned_dvds, 2, 'Has many relations created' ); ok( $owned_dvds{'temp name 1'}, 'Name in a has_many related record saved' ); diff --git a/t/pg.t b/t/pg.t index 58ce124..7a2294d 100644 --- a/t/pg.t +++ b/t/pg.t @@ -10,8 +10,6 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' . ' (note: creates and tables!)' unless ($dsn && $user); -plan tests => 19; - my $schema = DBSchema::get_test_schema( $dsn, $user, $pass ); run_tests( $schema ); diff --git a/t/sqlite.t b/t/sqlite.t index ae617b6..4517ccf 100644 --- a/t/sqlite.t +++ b/t/sqlite.t @@ -4,7 +4,6 @@ use lib 't/lib'; use DBSchema; use RunTests; use Test::More; -plan tests => 23; my $schema = DBSchema::get_test_schema(); run_tests( $schema ); diff --git a/t/var/dvdzbr.db b/t/var/dvdzbr.db index 6baf011..bac7b17 100644 Binary files a/t/var/dvdzbr.db and b/t/var/dvdzbr.db differ