Debian Codegraph @

t/20_createdrop.t

raw
1 #!/usr/bin/perl
2
3 # Test if a table can be created and dropped
4
5 use strict;
6 use warnings;
7 use Test::More;
8
9 BEGIN { use_ok ("DBI") }
10 do "./t/lib.pl";
11
12 my @tbl_def = (
13 [ "id", "INTEGER", 4, 0 ],
14 [ "name", "CHAR", 64, 0 ],
15 );
16
17 ok (my $dbh = Connect (), "connect");
18
19 ok (my $tbl = FindNewTable ($dbh), "find new test table");
20
21 like (my $def = TableDefinition ($tbl, @tbl_def),
22 qr{^create table $tbl}i, "table definition");
23 ok ($dbh->do ($def), "create table");
24 my $tbl_file = DbFile ($tbl);
25 ok (-s $tbl_file, "file exists");
26 ok ($dbh->do ("drop table $tbl"), "drop table");
27 ok ($dbh->disconnect, "disconnect");
28 ok (!-f $tbl_file, "file removed");
29
30 done_testing ();