mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
Removing the table name generator, since each test now uses it's own database
This commit is contained in:
parent
dfd5fc6f14
commit
e93d416d28
14 changed files with 20 additions and 57 deletions
|
@ -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' );
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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");
|
||||
|
||||
#
|
||||
|
|
|
@ -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);
|
||||
|
||||
#
|
||||
|
|
|
@ -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);
|
||||
|
||||
#
|
||||
|
|
|
@ -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);
|
||||
|
||||
#
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
#
|
||||
|
|
|
@ -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);
|
||||
|
||||
#
|
||||
|
|
|
@ -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);
|
||||
|
||||
#
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
44
t/lib.pl
44
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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
#
|
||||
|
|
Loading…
Add table
Reference in a new issue