DBIx-Custom / t / dbix-custom-sqlite.t /
Newer Older
58 lines | 1.653kb
packaging one directory
yuki-kimoto authored on 2009-11-16
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
table object call dbi object...
Yuki Kimoto authored on 2011-01-25
17
sub test { print "# $_[0]\n" }
packaging one directory
yuki-kimoto authored on 2009-11-16
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 ...
yuki-kimoto authored on 2010-01-30
32
my $id;
packaging one directory
yuki-kimoto authored on 2009-11-16
33

            
34
test 'connect_memory';
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
35
$dbi = DBIx::Custom::SQLite->connect_memory;
rename query() to execute()
yuki-kimoto authored on 2010-05-01
36
$ret_val = $dbi->execute($CREATE_TABLE->{0});
cleanup
Yuki Kimoto authored on 2011-01-23
37
ok(defined $ret_val);
removed register_format()
yuki-kimoto authored on 2010-05-26
38
$dbi->insert(table => 'table1', param => {key1 => 'a', key2 => 2});
39
$rows = $dbi->select(table => 'table1', where => {key1 => 'a'})->fetch_hash_all;
cleanup
Yuki Kimoto authored on 2011-01-23
40
is_deeply($rows, [{key1 => 'a', key2 => 2}], "select rows");
packaging one directory
yuki-kimoto authored on 2009-11-16
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
Yuki Kimoto authored on 2011-01-23
47
ok(-f $db_file, "database file");
rename query() to execute()
yuki-kimoto authored on 2010-05-01
48
$ret_val = $dbi->execute($CREATE_TABLE->{0});
cleanup
Yuki Kimoto authored on 2011-01-23
49
ok(defined $ret_val, "database");
removed DESTROY method(not b...
yuki-kimoto authored on 2010-07-18
50
$dbi->dbh->disconnect;
add tests
yuki-kimoto authored on 2010-08-10
51

            
packaging one directory
yuki-kimoto authored on 2009-11-16
52
unlink $db_file if -f $db_file;
add tests
yuki-kimoto authored on 2010-08-10
53
$dbi = DBIx::Custom::SQLite->connect(database => $db_file);
cleanup
Yuki Kimoto authored on 2011-01-23
54
ok($dbi, "called from class name");
packaging one directory
yuki-kimoto authored on 2009-11-16
55

            
add tests
yuki-kimoto authored on 2010-08-10
56
unlink $db_file if -f $db_file;
57
$dbi = DBIx::Custom::SQLite->connect(data_source => "dbi:SQLite:dbname=$db_file");
cleanup
Yuki Kimoto authored on 2011-01-23
58
ok($dbi, "specified data source");