Commit | Line | Data |
0567538f |
1 | sub run_tests { |
1edaf6fe |
2 | my $schema = shift; |
0567538f |
3 | |
e88a60b6 |
4 | plan tests => 2; |
0567538f |
5 | |
6 | # add some rows inside a transaction and commit it |
7 | # XXX: Is storage->dbh the only way to get a dbh? |
1edaf6fe |
8 | $schema->class("Artist")->txn_begin; |
0567538f |
9 | for (10..15) { |
1edaf6fe |
10 | $schema->class("Artist")->create( { |
0567538f |
11 | artistid => $_, |
12 | name => "artist number $_", |
13 | } ); |
14 | } |
1edaf6fe |
15 | $schema->class("Artist")->txn_commit; |
16 | my ($artist) = $schema->class("Artist")->find(15); |
0567538f |
17 | is($artist->name, 'artist number 15', "Commit ok"); |
18 | |
0567538f |
19 | # add some rows inside a transaction and roll it back |
1edaf6fe |
20 | $schema->class("Artist")->txn_begin; |
0567538f |
21 | for (21..30) { |
1edaf6fe |
22 | $schema->class("Artist")->create( { |
0567538f |
23 | artistid => $_, |
24 | name => "artist number $_", |
25 | } ); |
26 | } |
1edaf6fe |
27 | $schema->class("Artist")->txn_rollback; |
28 | ($artist) = $schema->class("Artist")->search( artistid => 25 ); |
0567538f |
29 | is($artist, undef, "Rollback ok"); |
30 | |
31 | } |
32 | |
33 | 1; |