List:Commits« Previous MessageNext Message »
From:capttofu Date:May 10 2008 12:25pm
Subject:[svn:DBD-mysql] r11234 - DBD-mysql/trunk/t
View as plain text  
Author: capttofu
Date: Sat May 10 05:25:31 2008
New Revision: 11234

Added:
   DBD-mysql/trunk/t/31insertid.t
      - copied unchanged from r11233, /DBD-mysql/trunk/t/insertid.t
   DBD-mysql/trunk/t/76multi_statement.t
      - copied unchanged from r11233, /DBD-mysql/trunk/t/multi_statement.t
Removed:
   DBD-mysql/trunk/t/insertid.t
   DBD-mysql/trunk/t/multi_statement.t
   DBD-mysql/trunk/t/param_values.t
Modified:
   DBD-mysql/trunk/t/40server_prepare.t
   DBD-mysql/trunk/t/prepare_noerror.t
   DBD-mysql/trunk/t/texecute.t

Log:
More tests - renamed


Modified: DBD-mysql/trunk/t/40server_prepare.t
==============================================================================
--- DBD-mysql/trunk/t/40server_prepare.t	(original)
+++ DBD-mysql/trunk/t/40server_prepare.t	Sat May 10 05:25:31 2008
@@ -1,26 +1,26 @@
 #!perl -w
 # vim: ft=perl
 
-use Test::More tests => 9;
-use DBI;
 use strict;
-$|= 1;
+use Test::More;
+use DBI;
+use lib 't', '.';
+require 'lib.pl';
+use vars qw($table $test_dsn $test_user $test_password);
 
-my $mdriver= "";
-our ($test_dsn, $test_user, $test_password);
-foreach my $file ("lib.pl", "t/lib.pl") {
-  do $file;
-  if ($@) {
-    print STDERR "Error while executing $file: $@\n";
-    exit 10;
-  }
-  last if $mdriver ne '';
-}
+$|= 1;
 
 $test_dsn.= ";mysql_server_prepare=1";
 
-my $dbh= DBI->connect($test_dsn, $test_user, $test_password,
-                      { RaiseError => 1, PrintError => 1, AutoCommit => 0 });
+my $dbh;
+eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
+                      { RaiseError => 1, PrintError => 1, AutoCommit => 0 });};
+
+if ($@) {
+    plan skip_all => "ERROR: $@. Can't continue test";
+}
+plan tests => 9; 
+
 ok(defined $dbh, "connecting");
 
 ok($dbh->do(qq{DROP TABLE IF EXISTS t1}), "making slate clean");

Modified: DBD-mysql/trunk/t/prepare_noerror.t
==============================================================================
--- DBD-mysql/trunk/t/prepare_noerror.t	(original)
+++ DBD-mysql/trunk/t/prepare_noerror.t	Sat May 10 05:25:31 2008
@@ -1,74 +1,47 @@
-# -*- cperl -*-
+#!perl -w
+# vim: ft=perl
 # Test problem in 3.0002_4 and 3.0005 where if a statement is prepared
 # and multiple executes are performed, if any execute fails all subsequent
 # executes report an error but may have worked.
 
 use strict;
 use DBI ();
-use Data::Dumper;
+use DBI::Const::GetInfoType;
+use Test::More;
+use lib '.', 't';
+require 'lib.pl';
+
+use vars qw($test_dsn $test_user $test_password);
+
+$test_dsn.= ";mysql_server_prepare=1";
+my $dbh;
+eval {$dbh = DBI->connect($test_dsn, $test_user, $test_password,
+  { RaiseError => 1, AutoCommit => 1})};
 
-use vars qw($test_dsn $test_user $test_password $state);
-my ($mdriver,$file) = ('','');
-foreach $file ("lib.pl", "t/lib.pl")
-{
-  do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
-    exit 10;
-  }
-  if ($mdriver ne '') {
-    last;
-  }
+if ($@) {
+    plan skip_all => "ERROR: $@. Can't continue test";
 }
 
-my $tmp_dbh= DBI->connect("$test_dsn",
-  $test_user, $test_password, {RaiseError => 0});
-
-my $tmp_sth= $tmp_dbh->prepare("select version()"); 
-
-$tmp_sth->execute();
-
-my $tmp_ref= $tmp_sth->fetchall_arrayref();
-
-my $tmp_version= $tmp_ref->[0][0];
-
-$tmp_version =~ /^(\d)\.(\d)/;
-#print "version $tmp_version version # $1 dot $2\n";
-
-$tmp_sth->finish();
-$tmp_dbh->disconnect();
-
-if ($1 < 5 && $2 < 1)
-{
-  print "1..0 # Skip test - will only run with MySQL 4.1 and above.\n";
-  exit(0);
-}
-if ($test_dsn =~ /emulated/)
-{
-  print "1..0 # Skip test - will only run in server-side prepare mode.\n";
-  exit(0);
+# 
+# DROP/CREATE PROCEDURE will give syntax error 
+# for versions < 5.0
+#
+if ($dbh->get_info($GetInfoType{SQL_DBMS_VER}) lt "4.1") {
+    plan skip_all => 
+        "SKIP TEST: You must have MySQL version 4.1 and greater for this test to run";
 }
+plan tests => 3;
 
+# execute invalid SQL to make sure we get an error
+my $q = "select select select";	# invalid SQL
+$dbh->{PrintError} = 0;
+$dbh->{PrintWarn} = 0;
+my $sth;
+eval {$sth = $dbh->prepare($q);};
+$dbh->{PrintError} = 1;
+$dbh->{PrintWarn} = 1;
+ok defined($DBI::errstr);
+cmp_ok $DBI::errstr, 'ne', '';
 
-while (Testing()) {
-  my ($dbh, $sth);
-  #
-  # Connect to the database
-  Test($state or
-       ($dbh = DBI->connect("$test_dsn;mysql_server_prepare=1", $test_user,
$test_password,
-                           {RaiseError => 0})));
-
-  #
-  # execute invalid SQL to make sure we get an error
-  #
-  my $q = "select select select";	# invalid SQL
-  $dbh->{PrintError} = 0;
-  $dbh->{PrintWarn} = 0;
-  eval {$sth = $dbh->prepare($q);};
-  $dbh->{PrintError} = 1;
-  $dbh->{PrintWarn} = 1;
-  Test($state or (defined($DBI::errstr) && ($DBI::errstr ne "")));
-  print "errstr $DBI::errstr\n" if $DBI::errstr;
-  #
-  # Close the database connection
-  Test($state or ($dbh->disconnect() or 1));
-}
-
+print "errstr $DBI::errstr\n" if $DBI::errstr;
+ok $dbh->disconnect();

Modified: DBD-mysql/trunk/t/texecute.t
==============================================================================
--- DBD-mysql/trunk/t/texecute.t	(original)
+++ DBD-mysql/trunk/t/texecute.t	Sat May 10 05:25:31 2008
@@ -1,54 +1,51 @@
-# -*- cperl -*-
+#!perl -w
+# vim: ft=perl
 # Test problem in 3.0002_4 and 3.0005 where if a statement is prepared
 # and multiple executes are performed, if any execute fails all subsequent
 # executes report an error but may have worked.
 
 use strict;
 use DBI ();
+use DBI::Const::GetInfoType;
+use Test::More;
+use lib '.', 't';
+require 'lib.pl';
+
+use vars qw($table $test_dsn $test_user $test_password);
+
+my $dbh;
+eval {$dbh = DBI->connect($test_dsn, $test_user, $test_password,
+  { RaiseError => 1, AutoCommit => 1})};
 
-use vars qw($test_dsn $test_user $test_password $state);
-require "t/lib.pl";
-
-while (Testing()) {
-  my ($dbh, $sth);
-  #
-
-  # Connect to the database
-  Test($state or
-       ($dbh = DBI->connect($test_dsn, $test_user, $test_password,
-                           {RaiseError => 0})));
-
-  # Find a possible new table name
-  #
-  my $table = 't1';
-  # Drop the table
-  Test($state or $dbh->do("DROP TABLE IF EXISTS $table"));
-  #
-  # Create a new table
-  #
-  my $q = <<"QUERY";
-CREATE TABLE $table (id INTEGER PRIMARY KEY NOT NULL,
-                     name VARCHAR(64))
-QUERY
-  Test($state or $dbh->do($q));
-
-  #
-  # Insert a row
-  #
-  $q = "INSERT INTO $table (id, name) VALUES (?,?)";
-  Test($state or ($sth = $dbh->prepare($q)));
-  Test($state or $sth->execute(1, "Jocken"));
-  $sth->{PrintError} = 0;
-  Test($state or !($sth->execute(1, "Jochen")));
-  $sth->{PrintError} = 1;
-  Test($state or $sth->execute(2, "Jochen"));
-
-  #
-  # Drop the table
-  Test($state or $dbh->do("DROP TABLE $table"));
-
-  #
-  # Close the database connection
-  Test($state or ($dbh->disconnect() or 1));
+if ($@) {
+    plan skip_all => "ERROR: $@. Can't continue test";
 }
+plan tests => 8;
+
+ok $dbh->do("DROP TABLE IF EXISTS $table");
+
+my $create = <<EOT;
+CREATE TABLE $table (
+    id INT(3) PRIMARY KEY NOT NULL,
+    name VARCHAR(64))
+EOT
+
+ok $dbh->do($create);
+
+my $query = "INSERT INTO $table (id, name) VALUES (?,?)";
+my $sth = $dbh->prepare($query) or die "$DBI::errstr";
+
+ok $sth->execute(1, "Jocken");
+
+$sth->{PrintError} = 0;
+eval {$sth->execute(1, "Jochen")};
+ok ($@), 'fails with duplicate entry';
+
+$sth->{PrintError} = 1;
+ok $sth->execute(2, "Jochen");
+
+ok $sth->finish;
+
+ok $dbh->do("DROP TABLE $table");
 
+ok $dbh->disconnect();
Thread
[svn:DBD-mysql] r11234 - DBD-mysql/trunk/tcapttofu10 May