DBIx-Custom / t / dbix-custom-mysql-private.t /
Newer Older
51 lines | 1.127kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
use Test::More;
2
use strict;
3
use warnings;
4

            
5
# user password database
6
our ($USER, $PASSWORD, $DATABASE) = connect_info();
7

            
8
plan skip_all => 'private MySQL test' unless $USER;
9

            
10
plan 'no_plan';
11

            
12
# Function for test name
13
my $test;
14
sub test {
15
    $test = shift;
16
}
17

            
18

            
19
# Functions for tests
20
sub connect_info {
21
    my $file = 'password.tmp';
22
    open my $fh, '<', $file
23
      or return;
24
    
25
    my ($user, $password, $database) = split(/\s/, (<$fh>)[0]);
26
    
27
    close $fh;
28
    
29
    return ($user, $password, $database);
30
}
31

            
32

            
33
# Varialbes for tests
34
my $dbi;
add tests
yuki-kimoto authored on 2010-08-10
35
my $dbname;
packaging one directory
yuki-kimoto authored on 2009-11-16
36

            
37
use DBIx::Custom::MySQL;
38

            
39
test 'connect';
add tests
yuki-kimoto authored on 2010-08-10
40
$dbi = DBIx::Custom::MySQL->new(user => $USER, password => $PASSWORD,
41
                    database => $DATABASE, host => 'localhost', port => '10000');
packaging one directory
yuki-kimoto authored on 2009-11-16
42
$dbi->connect;
add tests
yuki-kimoto authored on 2010-08-10
43
like($dbi->data_source, qr/dbi:mysql:database=.*;host=localhost;port=10000;/, "$test : created data source");
packaging one directory
yuki-kimoto authored on 2009-11-16
44
is(ref $dbi->dbh, 'DBI::db', $test);
45

            
update document
yuki-kimoto authored on 2010-05-27
46
test 'attributes';
47
$dbi = DBIx::Custom::MySQL->new;
48
$dbi->host('a');
49
is($dbi->host, 'a', "$test: host");
50
$dbi->port('b');
51
is($dbi->port, 'b', "$test: port");