diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2012-09-24 10:15:50 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-26 13:46:46 +0000 |
commit | 485b97be9f2f2abf5a40923b5fd85f75714a8c02 (patch) | |
tree | ca05cb0ecf3828d909a898c3e5805804a0aff5f8 /t/02_logon.t | |
download | perl-dbd-sqlite-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/perl-dbd-sqlite-tarball/DBD-SQLite-1.38_01.tar.gz.HEADDBD-SQLite-1.38_01masterbaserock/morph
Diffstat (limited to 't/02_logon.t')
-rw-r--r-- | t/02_logon.t | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/t/02_logon.t b/t/02_logon.t new file mode 100644 index 0000000..a8c607d --- /dev/null +++ b/t/02_logon.t @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +# Tests basic login and pragma setting + +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +use t::lib::Test qw/connect_ok @CALL_FUNCS/; +use Test::More; +use Test::NoWarnings; + +plan tests => 18 * @CALL_FUNCS + 1; + +my $show_diag = 0; +foreach my $call_func (@CALL_FUNCS) { + + # Ordinary connect + SCOPE: { + my $dbh = connect_ok(); + ok( $dbh->{sqlite_version}, '->{sqlite_version} ok' ); + is( $dbh->{AutoCommit}, 1, 'AutoCommit is on by default' ); + diag("sqlite_version=$dbh->{sqlite_version}") unless $show_diag++; + ok( $dbh->$call_func('busy_timeout'), 'Found initial busy_timeout' ); + ok( $dbh->$call_func(5000, 'busy_timeout') ); + is( $dbh->$call_func('busy_timeout'), 5000, 'Set busy_timeout to new value' ); + } + + # Attributes in the connect string + SKIP: { + unless ( $] >= 5.008005 ) { + skip( 'Unicode is not supported before 5.8.5', 2 ); + } + my $file = 'foo'.$$; + my $dbh = DBI->connect( "dbi:SQLite:dbname=$file;sqlite_unicode=1", '', '' ); + isa_ok( $dbh, 'DBI::db' ); + is( $dbh->{sqlite_unicode}, 1, 'Unicode is on' ); + $dbh->disconnect; + unlink $file; + } + + # dbname, db, database + SCOPE: { + for my $key (qw/database db dbname/) { + my $file = 'foo'.$$; + unlink $file if -f $file; + ok !-f $file, 'database file does not exist'; + my $dbh = DBI->connect("dbi:SQLite:$key=$file"); + isa_ok( $dbh, 'DBI::db' ); + ok -f $file, "database file (specified by $key=$file) now exists"; + $dbh->disconnect; + unlink $file; + } + } + + # Connect to a memory database + SCOPE: { + my $dbh = DBI->connect( 'dbi:SQLite:dbname=:memory:', '', '' ); + isa_ok( $dbh, 'DBI::db' ); + } +} |