[Jifty-commit] r6781 - Jifty-DBI/trunk/t
Jifty commits
jifty-commit at lists.jifty.org
Wed Apr 15 13:44:05 EDT 2009
Author: ruz
Date: Wed Apr 15 13:44:05 2009
New Revision: 6781
Added:
Jifty-DBI/trunk/t/03rename_table.t
Log:
* test rename_table
Added: Jifty-DBI/trunk/t/03rename_table.t
==============================================================================
--- (empty file)
+++ Jifty-DBI/trunk/t/03rename_table.t Wed Apr 15 13:44:05 2009
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl -w
+
+
+use strict;
+use warnings;
+use File::Spec;
+use Test::More;
+use Jifty::DBI::Handle;
+
+BEGIN { require "t/utils.pl" }
+our (@available_drivers);
+
+use constant TESTS_PER_DRIVER => 6;
+
+my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
+plan tests => $total;
+
+foreach my $d ( @available_drivers ) {
+SKIP: {
+ unless( should_test( $d ) ) {
+ skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
+ }
+
+ my $handle = get_handle($d);
+ connect_handle($handle);
+ isa_ok( $handle->dbh, 'DBI::db' );
+
+ my $sth;
+ $sth = $handle->simple_query("DROP TABLE IF EXISTS test") if $d eq 'mysql';
+ $sth = $handle->simple_query("DROP TABLE IF EXISTS test1") if $d eq 'mysql';
+
+ $sth = $handle->simple_query("CREATE TABLE test (a int)");
+ ok $sth, 'created a table';
+
+ ok $handle->simple_query("insert into test values(1)"), "inserted a record";
+ is $handle->simple_query("select * from test")->fetchrow_hashref->{'a'},
+ 1, 'correct value';
+
+ $handle->rename_table( table => 'test', to => 'test1' );
+
+ is $handle->simple_query("select * from test1")->fetchrow_hashref->{'a'},
+ 1, 'correct value';
+
+ ok !eval { $handle->simple_query("select * from test") },
+ "no test table anymore";
+
+}} # SKIP, foreach blocks
+
+1;
More information about the Jifty-commit
mailing list