File: 02_logon.t

package info (click to toggle)
libdbd-sqlite3-perl 1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,004 kB
  • sloc: ansic: 167,715; perl: 1,788; pascal: 277; makefile: 9
file content (65 lines) | stat: -rw-r--r-- 1,848 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Tests basic login and pragma setting

use strict;
use warnings;
use lib "t/lib";
use SQLiteTest qw/connect_ok @CALL_FUNCS/;
use Test::More;
use if -d ".git", "Test::FailWarnings";

use DBD::SQLite::Constants ':dbd_sqlite_string_mode';

my $unicode_opt = DBD_SQLITE_STRING_MODE_UNICODE_STRICT;

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' );

		ok( defined $dbh->$call_func(0, 'busy_timeout') );
		is( $dbh->$call_func('busy_timeout'), 0, 'Set busy_timeout to 0' );
	}

	# 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_string_mode=$unicode_opt", '', '' );
		isa_ok( $dbh, 'DBI::db' );
		is( $dbh->{sqlite_string_mode}, $unicode_opt, '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' );	
	}
}

done_testing;