From e93d416d28737409a060c2c24f4abb2c561b01a8 Mon Sep 17 00:00:00 2001 From: Adam Kennedy Date: Thu, 16 Apr 2009 00:54:21 +0000 Subject: [PATCH] Removing the table name generator, since each test now uses it's own database --- t/02_logon.t | 8 +++++++- t/10_create_aggregate.t | 3 ++- t/15_ak_dbd.t | 2 +- t/17_createdrop.t | 2 +- t/18_insertfetch.t | 2 +- t/19_bindparam.t | 2 +- t/20_blobs.t | 2 +- t/22_listfields.t | 2 +- t/23_nulls.t | 2 +- t/24_numrows.t | 2 +- t/25_chopblanks.t | 2 +- t/26_commit.t | 2 +- t/lib.pl | 44 ----------------------------------------- t/rt_15186_prepcached.t | 2 +- 14 files changed, 20 insertions(+), 57 deletions(-) diff --git a/t/02_logon.t b/t/02_logon.t index 89fd7c5..2814a3b 100644 --- a/t/02_logon.t +++ b/t/02_logon.t @@ -9,7 +9,7 @@ BEGIN { } use t::lib::Test; -use Test::More tests => 9; +use Test::More tests => 10; use Test::NoWarnings; # Ordinary connect @@ -32,3 +32,9 @@ SKIP: { isa_ok( $dbh, 'DBI::db' ); is( $dbh->{unicode}, 1, 'Unicode is on' ); } + +# Connect to a memory database +SCOPE: { + my $dbh = DBI->connect( 'dbi:SQLite:dbname=:memory:', '', '' ); + isa_ok( $dbh, 'DBI::db' ); +} diff --git a/t/10_create_aggregate.t b/t/10_create_aggregate.t index 174f1fa..b42edb8 100644 --- a/t/10_create_aggregate.t +++ b/t/10_create_aggregate.t @@ -6,8 +6,9 @@ BEGIN { $^W = 1; } -use Test::More tests => 15; use t::lib::Test; +use Test::More tests => 15; +use Test::NoWarnings; # Create the aggregate test packages SCOPE: { diff --git a/t/15_ak_dbd.t b/t/15_ak_dbd.t index 8d39fe3..c395fe3 100644 --- a/t/15_ak_dbd.t +++ b/t/15_ak_dbd.t @@ -34,7 +34,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or $test_table = FindNewTable($dbh)) or 1 + Test($state or $test_table = 'table1') or 1 or ErrMsg("Cannot get table name: $dbh->errstr.\n"); # diff --git a/t/17_createdrop.t b/t/17_createdrop.t index 8946022..83eb823 100644 --- a/t/17_createdrop.t +++ b/t/17_createdrop.t @@ -45,7 +45,7 @@ while (Testing()) { # Find a possible new table name # my $table; - Test($state or $table = FindNewTable($dbh)) + Test($state or $table = 'table1') or DbiError($dbh->err, $dbh->errstr); # diff --git a/t/18_insertfetch.t b/t/18_insertfetch.t index 9223304..b387d10 100644 --- a/t/18_insertfetch.t +++ b/t/18_insertfetch.t @@ -47,7 +47,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or $table = FindNewTable($dbh), 'FindNewTable') + Test($state or $table = 'table1') or DbiError($dbh->err, $dbh->errstr); # diff --git a/t/19_bindparam.t b/t/19_bindparam.t index d48f275..d1e2f1d 100644 --- a/t/19_bindparam.t +++ b/t/19_bindparam.t @@ -60,7 +60,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or $table = FindNewTable($dbh), 'FindNewTable') + Test($state or $table = 'table1') or DbiError($dbh->err, $dbh->errstr); # diff --git a/t/20_blobs.t b/t/20_blobs.t index 8be6fce..ed815c2 100644 --- a/t/20_blobs.t +++ b/t/20_blobs.t @@ -76,7 +76,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or $table = FindNewTable($dbh)) + Test($state or $table = 'table1') or DbiError($dbh->error, $dbh->errstr); my($def); diff --git a/t/22_listfields.t b/t/22_listfields.t index a5e05e4..d5b64f1 100644 --- a/t/22_listfields.t +++ b/t/22_listfields.t @@ -54,7 +54,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or $table = FindNewTable($dbh)) + Test($state or $table = 'table1') or DbiError($dbh->err, $dbh->errstr); # diff --git a/t/23_nulls.t b/t/23_nulls.t index acc9292..7c8deb1 100644 --- a/t/23_nulls.t +++ b/t/23_nulls.t @@ -48,7 +48,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or $table = FindNewTable($dbh)) + Test($state or $table = 'table1') or DbiError($dbh->err, $dbh->errstr); # diff --git a/t/24_numrows.t b/t/24_numrows.t index e20aac7..7d84ac2 100644 --- a/t/24_numrows.t +++ b/t/24_numrows.t @@ -57,7 +57,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or ($table = FindNewTable($dbh))) + Test($state or ($table = 'table1')) or DbiError($dbh->err, $dbh->errstr); # diff --git a/t/25_chopblanks.t b/t/25_chopblanks.t index b719656..d40e7b6 100644 --- a/t/25_chopblanks.t +++ b/t/25_chopblanks.t @@ -52,7 +52,7 @@ while (Testing()) { # Find a possible new table name # my $table = ''; - Test($state or $table = FindNewTable($dbh)) + Test($state or $table = 'table1') or ErrMsgF("Cannot determine a legal table name: Error %s.\n", $dbh->errstr); diff --git a/t/26_commit.t b/t/26_commit.t index 83a96dc..727acc2 100644 --- a/t/26_commit.t +++ b/t/26_commit.t @@ -71,7 +71,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or $table = FindNewTable($dbh)) + Test($state or $table = 'table1') or ErrMsgF("Cannot determine a legal table name: Error %s.\n", $dbh->errstr); diff --git a/t/lib.pl b/t/lib.pl index eef2560..32ce921 100644 --- a/t/lib.pl +++ b/t/lib.pl @@ -215,51 +215,7 @@ sub DbiError ($$) { print "Test $::numTests: DBI error $rc, $err\n"; } - -# -# This functions generates a list of possible DSN's aka -# databases and returns a possible table name for a new -# table being created. -SCOPE: { - my(@tables, $testtable, $listed); - - $testtable = "testaa"; - $listed = 0; - - sub FindNewTable($) { - my($dbh) = @_; - - if (!$listed) { - @tables = $dbh->func('list_tables'); - if ($dbh->errstr) { - die "Cannot create table list: " . $dbh->errstr; - } - $listed = 1; - } - - # A small loop to find a free test table we can use to mangle stuff in - # and out of. This starts at testaa and loops until testaz, then testba - # - testbz and so on until testzz. - my $foundtesttable = 1; - my $table; - while ($foundtesttable) { - $foundtesttable = 0; - foreach $table (@tables) { - if ($table eq $testtable) { - $testtable++; - $foundtesttable = 1; - } - } - } - $table = $testtable; - $testtable++; - $table; - } -} - - sub ErrMsg { print (@_); } sub ErrMsgF { printf (@_); } - 1; diff --git a/t/rt_15186_prepcached.t b/t/rt_15186_prepcached.t index da93267..d3ce96d 100644 --- a/t/rt_15186_prepcached.t +++ b/t/rt_15186_prepcached.t @@ -60,7 +60,7 @@ while (Testing()) { # # Find a possible new table name # - Test($state or ($table = FindNewTable($dbh))) + Test($state or $table = 'table1') or DbiError($dbh->err, $dbh->errstr); #