Commit | Line | Data |
0567538f |
1 | sub run_tests { |
2 | |
e88a60b6 |
3 | plan 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? |
3712e4f4 |
7 | DBICTest->class("Artist")->txn_begin; |
0567538f |
8 | for (10..15) { |
3712e4f4 |
9 | DBICTest->class("Artist")->create( { |
0567538f |
10 | artistid => $_, |
11 | name => "artist number $_", |
12 | } ); |
13 | } |
3712e4f4 |
14 | DBICTest->class("Artist")->txn_commit; |
15 | my ($artist) = DBICTest->class("Artist")->find(15); |
0567538f |
16 | is($artist->name, 'artist number 15', "Commit ok"); |
17 | |
0567538f |
18 | # add some rows inside a transaction and roll it back |
3712e4f4 |
19 | DBICTest->class("Artist")->txn_begin; |
0567538f |
20 | for (21..30) { |
3712e4f4 |
21 | DBICTest->class("Artist")->create( { |
0567538f |
22 | artistid => $_, |
23 | name => "artist number $_", |
24 | } ); |
25 | } |
3712e4f4 |
26 | DBICTest->class("Artist")->txn_rollback; |
27 | ($artist) = DBICTest->class("Artist")->search( artistid => 25 ); |
0567538f |
28 | is($artist, undef, "Rollback ok"); |
29 | |
30 | } |
31 | |
32 | 1; |