X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F73oracle.t;h=b372adb9def5c47bda5721abb457cbaebd68f6c8;hb=a5a27e7a8da524a8ad4154f3c3a167d98a89a2f0;hp=ca373cb51c6869c0a7ef7e2557cf9111e69a8614;hpb=f70b86f99991081454c96e305ba1c046473113b4;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/73oracle.t b/t/73oracle.t index ca373cb..b372adb 100644 --- a/t/73oracle.t +++ b/t/73oracle.t @@ -359,6 +359,57 @@ sub _run_tests { $schema->storage->debug ($orig_debug); }} +# test populate (identity, success and error handling) + my $art_rs = $schema->resultset('Artist'); + + my $seq_pos = $art_rs->get_column('artistid')->max; + ok($seq_pos, 'Starting with something in the artist table'); + + + my $pop_rs = $schema->resultset('Artist')->search( + { name => { -like => 'pop_art_%' } }, + { order_by => 'artistid' } + ); + + $art_rs->delete; + lives_ok { + $pop_rs->populate([ + map { +{ name => "pop_art_$_" } } + (1,2,3) + ]); + + is_deeply ( + [ $pop_rs->get_column('artistid')->all ], + [ map { $seq_pos + $_ } (1,2,3) ], + 'Sequence works after empty-table insertion' + ); + } 'Populate without identity does not throw'; + + lives_ok { + $pop_rs->populate([ + map { +{ artistid => $_, name => "pop_art_$_" } } + (1,2,3) + ]); + + is_deeply ( + [ $pop_rs->get_column('artistid')->all ], + [ 1,2,3, map { $seq_pos + $_ } (1,2,3) ], + 'Explicit id population works' + ); + } 'Populate with identity does not throw'; + + throws_ok { + $pop_rs->populate([ + map { +{ artistid => $_, name => "pop_art_$_" } } + (200, 1, 300) + ]); + } qr/unique constraint.+populate slice.+name => "pop_art_1"/s, 'Partially failed populate throws'; + + is_deeply ( + [ $pop_rs->get_column('artistid')->all ], + [ 1,2,3, map { $seq_pos + $_ } (1,2,3) ], + 'Partially failed populate did not alter table contents' + ); # test sequence detection from a different schema SKIP: {