[Bast-commits] r3849 - DBIx-Class/0.09/branches/savepoints/t
gphat at dev.catalyst.perl.org
gphat at dev.catalyst.perl.org
Thu Nov 1 02:10:27 GMT 2007
Author: gphat
Date: 2007-11-01 02:10:26 +0000 (Thu, 01 Nov 2007)
New Revision: 3849
Modified:
DBIx-Class/0.09/branches/savepoints/t/71mysql.t
Log:
Test savepoints in MySQL
Modified: DBIx-Class/0.09/branches/savepoints/t/71mysql.t
===================================================================
--- DBIx-Class/0.09/branches/savepoints/t/71mysql.t 2007-10-31 11:29:16 UTC (rev 3848)
+++ DBIx-Class/0.09/branches/savepoints/t/71mysql.t 2007-11-01 02:10:26 UTC (rev 3849)
@@ -1,9 +1,10 @@
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
use DBICTest;
+use DBICTest::Stats;
use DBI::Const::GetInfoType;
my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/};
@@ -13,15 +14,18 @@
plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
unless ($dsn && $user);
-plan tests => 5;
+plan tests => 9;
my $schema = DBICTest::Schema->connect($dsn, $user, $pass);
my $dbh = $schema->storage->dbh;
+my $stats = new DBICTest::Stats();
+$schema->storage->debugobj($stats);
+$schema->storage->debug(1);
$dbh->do("DROP TABLE IF EXISTS artist;");
-$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), charfield CHAR(10));");
+$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), charfield CHAR(10)) ENGINE=InnoDB;");
#'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
@@ -68,6 +72,32 @@
},
};
+$schema->txn_begin();
+
+my $arty = $schema->resultset('Artist')->find(1);
+
+my $name = $arty->name();
+
+$schema->svp_begin('savepoint1');
+
+cmp_ok($stats->{'SVP_BEGIN'}, '==', 1, 'Statistics svp_begin tickled');
+
+$arty->update({ name => 'Jheephizzy' });
+
+$arty->discard_changes();
+
+cmp_ok($arty->name(), 'eq', 'Jheephizzy', 'Name changed');
+
+$schema->svp_rollback('savepoint1');
+
+cmp_ok($stats->{'SVP_ROLLBACK'}, '==', 1, 'Statistics svp_rollback tickled');
+
+$arty->discard_changes();
+
+cmp_ok($arty->name(), 'eq', $name, 'Name rolled back');
+
+$schema->txn_commit();
+
SKIP: {
my $mysql_version = $dbh->get_info( $GetInfoType{SQL_DBMS_VER} );
skip "Cannot determine MySQL server version", 1 if !$mysql_version;
More information about the Bast-commits
mailing list