More test hackage, some cleanup in ResultSet
[dbsrgits/DBIx-Class.git] / t / run / 04db.tl
1 sub run_tests {
2 my $schema = shift;
3   
4 plan tests => 2;
5
6 # add some rows inside a transaction and commit it
7 # XXX: Is storage->dbh the only way to get a dbh?
8 $schema->storage->txn_begin;
9 for (10..15) {
10     $schema->resultset("Artist")->create( { 
11         artistid => $_,
12         name => "artist number $_",
13     } );
14 }
15 $schema->storage->txn_commit;
16 my ($artist) = $schema->resultset("Artist")->find(15);
17 is($artist->name, 'artist number 15', "Commit ok");
18
19 # add some rows inside a transaction and roll it back
20 $schema->storage->txn_begin;
21 for (21..30) {
22     $schema->resultset("Artist")->create( {
23         artistid => $_,
24         name => "artist number $_",
25     } );
26 }
27 $schema->storage->txn_rollback;
28 ($artist) = $schema->resultset("Artist")->search( artistid => 25 );
29 is($artist, undef, "Rollback ok");
30
31 }
32
33 1;