Showing 2 changed files with 77 additions and 0 deletions
+39
t/02-sqlite.t
... ...
@@ -0,0 +1,39 @@
1
+use Test::More;
2
+use strict;
3
+use warnings;
4
+
5
+BEGIN {
6
+    eval { require DBD::SQLite; 1 }
7
+        or plan skip_all => 'DBD::SQLite required';
8
+    eval { DBD::SQLite->VERSION >= 1 }
9
+        or plan skip_all => 'DBD::SQLite >= 1.00 required';
10
+
11
+    plan 'no_plan';
12
+    use_ok('DBI::Custom');
13
+}
14
+
15
+my $dbi = DBI::Custom->new(
16
+   connect_info => {data_source => 'dbi:SQLite:dbname=:memory:'}
17
+);
18
+
19
+$dbi->query_raw_sql("create table t1 (k1 char(10), k2 char(10))");
20
+
21
+{
22
+    $dbi->query("insert into t1 {insert_values}",{insert_values => {k1 => 1, k2 => 2}});
23
+    
24
+    $dbi->fetch_filter(sub {
25
+        my ($key, $value) = @_;
26
+        if ($key eq 'k1' && $value == 1 ) {
27
+            return $value * 3;
28
+        }
29
+        return $value;
30
+    });
31
+    
32
+    my $result = $dbi->query("select k1, k2 from t1");
33
+    
34
+    my $row = $result->fetchrow_arrayref;
35
+    my @values = @$row;
36
+    $result->finish;
37
+    
38
+    is_deeply(\@values, [3, 2]);
39
+}
+38
t/99-mysql_private.t
... ...
@@ -0,0 +1,38 @@
1
+use Test::More;
2
+use strict;
3
+use warnings;
4
+
5
+# user password database
6
+our ($U, $P, $D) = connect_info();
7
+
8
+plan skip_all => 'private MySQL test' unless $U;
9
+
10
+plan 'no_plan';
11
+
12
+use DBI::Custom;
13
+use Scalar::Util 'blessed';
14
+{
15
+    my $dbi = DBI::Custom->new(
16
+        connect_info => {
17
+            user => $U,
18
+            password => $P,
19
+            data_source => "dbi:mysql:$D"
20
+        }
21
+    );
22
+    $dbi->connect;
23
+    
24
+    ok(blessed $dbi->dbh);
25
+    can_ok($dbi->dbh, qw/prepare/);
26
+}
27
+
28
+sub connect_info {
29
+    my $file = 'password.tmp';
30
+    open my $fh, '<', $file
31
+      or return;
32
+    
33
+    my ($user, $password, $database) = split(/\s/, (<$fh>)[0]);
34
+    
35
+    close $fh;
36
+    
37
+    return ($user, $password, $database);
38
+}