Yeah, committing the new tests would help ...
[dbsrgits/DBIx-Class.git] / t / run / 04db.tl
CommitLineData
0567538f 1sub run_tests {
2
3plan tests => 3;
4
5# add some rows inside a transaction and commit it
6# XXX: Is storage->dbh the only way to get a dbh?
7DBICTest::Artist->storage->dbh->{AutoCommit} = 0;
8for (10..15) {
9 DBICTest::Artist->create( {
10 artistid => $_,
11 name => "artist number $_",
12 } );
13}
14DBICTest::Artist->dbi_commit;
15my ($artist) = DBICTest::Artist->find(15);
16is($artist->name, 'artist number 15', "Commit ok");
17
18# repeat the test using AutoCommit = 1 to force the commit
19DBICTest::Artist->storage->dbh->{AutoCommit} = 0;
20for (16..20) {
21 DBICTest::Artist->create( {
22 artistid => $_,
23 name => "artist number $_",
24 } );
25}
26DBICTest::Artist->storage->dbh->{AutoCommit} = 1;
27($artist) = DBICTest::Artist->find(20);
28is($artist->name, 'artist number 20', "Commit using AutoCommit ok");
29
30# add some rows inside a transaction and roll it back
31DBICTest::Artist->storage->dbh->{AutoCommit} = 0;
32for (21..30) {
33 DBICTest::Artist->create( {
34 artistid => $_,
35 name => "artist number $_",
36 } );
37}
38DBICTest::Artist->dbi_rollback;
39($artist) = DBICTest::Artist->search( artistid => 25 );
40is($artist, undef, "Rollback ok");
41
42}
43
441;