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