File: 1.t

package info (click to toggle)
libclass-dbi-plugin-type-perl 0.02-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 112 kB
  • sloc: perl: 33; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 983 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
package DBI::Test;

use Test::More;
if (!require DBD::SQLite) {
    plan skip_all => "Couldn't load DBD::SQLite";
}
plan tests => 6;

use base 'Class::DBI';

unlink 't/test.db';
DBI::Test->set_db("Main", "dbi:SQLite:dbname=t/test.db");
#DBI::Test->set_db("Main", "dbi:mysql:dbname=beerdb");
eval { DBI::Test->db_Main->do("DROP TABLE test") };
DBI::Test->db_Main->do("CREATE TABLE test (
    id int not null,
    brewery integer,
    style integer,
    name varchar(30),
    url varchar(120),
    tasted date,
    score integer(2),
    notes text,
    price decimal(4,2)
)");
DBI::Test->table("test");
use_ok('Class::DBI::Plugin::Type');
like(DBI::Test->column_type("notes"), qr/text|blob/i, "notes is text");
is(DBI::Test->column_type("tasted"), "date", "tasted is a date");
like(DBI::Test->column_type("price"), qr/^decimal/, "price is decimal");
like(DBI::Test->column_type("id"), qr/^int/i, "id is integer");
like(DBI::Test->column_type("name"), qr/^varchar/, "name is varchar");