packaging one directory
|
1 |
use Test::More; |
2 |
use strict; |
|
3 |
use warnings; |
|
4 |
use utf8; |
|
5 | ||
6 |
BEGIN { |
|
7 |
eval { require DBD::SQLite; 1 } |
|
8 |
or plan skip_all => 'DBD::SQLite required'; |
|
9 |
eval { DBD::SQLite->VERSION >= 1.25 } |
|
10 |
or plan skip_all => 'DBD::SQLite >= 1.25 required'; |
|
11 | ||
12 |
plan 'no_plan'; |
|
13 |
use_ok('DBIx::Custom::SQLite'); |
|
14 |
} |
|
15 | ||
16 |
# Function for test name |
|
cleanup
|
17 |
sub test { "# $_[0]\n" } |
packaging one directory
|
18 | |
19 |
# Constant varialbes for test |
|
20 |
my $CREATE_TABLE = { |
|
21 |
0 => 'create table table1 (key1 char(255), key2 char(255));', |
|
22 |
1 => 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));', |
|
23 |
2 => 'create table table2 (key1 char(255), key3 char(255));' |
|
24 |
}; |
|
25 | ||
26 | ||
27 |
# Variables for tests |
|
28 |
my $dbi; |
|
29 |
my $ret_val; |
|
30 |
my $rows; |
|
31 |
my $db_file; |
|
rename DBIx::Custom::SQLite ...
|
32 |
my $id; |
packaging one directory
|
33 | |
34 |
test 'connect_memory'; |
|
removed DESTROY method(not b...
|
35 |
$dbi = DBIx::Custom::SQLite->connect_memory; |
rename query() to execute()
|
36 |
$ret_val = $dbi->execute($CREATE_TABLE->{0}); |
cleanup
|
37 |
ok(defined $ret_val); |
removed register_format()
|
38 |
$dbi->insert(table => 'table1', param => {key1 => 'a', key2 => 2}); |
39 |
$rows = $dbi->select(table => 'table1', where => {key1 => 'a'})->fetch_hash_all; |
|
cleanup
|
40 |
is_deeply($rows, [{key1 => 'a', key2 => 2}], "select rows"); |
packaging one directory
|
41 | |
42 |
test 'connect'; |
|
43 |
$db_file = 't/test.db'; |
|
44 |
unlink $db_file if -f $db_file; |
|
45 |
$dbi = DBIx::Custom::SQLite->new(database => $db_file); |
|
46 |
$dbi->connect; |
|
cleanup
|
47 |
ok(-f $db_file, "database file"); |
rename query() to execute()
|
48 |
$ret_val = $dbi->execute($CREATE_TABLE->{0}); |
cleanup
|
49 |
ok(defined $ret_val, "database"); |
removed DESTROY method(not b...
|
50 |
$dbi->dbh->disconnect; |
add tests
|
51 | |
packaging one directory
|
52 |
unlink $db_file if -f $db_file; |
add tests
|
53 |
$dbi = DBIx::Custom::SQLite->connect(database => $db_file); |
cleanup
|
54 |
ok($dbi, "called from class name"); |
packaging one directory
|
55 | |
add tests
|
56 |
unlink $db_file if -f $db_file; |
57 |
$dbi = DBIx::Custom::SQLite->connect(data_source => "dbi:SQLite:dbname=$db_file"); |
|
cleanup
|
58 |
ok($dbi, "specified data source"); |