File: 72_csv-schema.t

package info (click to toggle)
libdbd-csv-perl 0.4500-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 320 kB
  • ctags: 55
  • sloc: perl: 2,142; makefile: 4
file content (51 lines) | stat: -rw-r--r-- 1,135 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl

use strict;
use warnings;
use Test::More;

BEGIN { use_ok ("DBI"); }
do "t/lib.pl";

my @tbl_def = (
    [ "id",   "INTEGER",  4, 0 ],
    [ "name", "CHAR",    64, 0 ],
    );

my $dir = DbDir ();

ok (my $dbh = DBI->connect ("dbi:CSV:", "", "", {
	f_dir	=> $dir,
	}),					"connect");

ok (my $tbl = FindNewTable ($dbh),		"find new test table");
like (my $def = TableDefinition ($tbl, @tbl_def),
    qr{^create table $tbl}i,			"table definition");
ok ($dbh->do ($def),				"create table");

my @tbl = $dbh->tables ();
if (my $usr = eval { getpwuid $< }) {
    s/^(['"`])(.+)\1\./$2./ for @tbl;
    is_deeply (\@tbl, [ qq{$usr.$tbl} ],	"tables");
    }
else {
    is_deeply (\@tbl, [ qq{$tbl}      ],	"tables");
    }

ok ($dbh->disconnect,				"disconnect");
undef $dbh;

ok ($dbh = DBI->connect ("dbi:CSV:", "", "", {
    f_schema	=> undef,
    f_dir	=> $dir,
    }),						"connect (f_schema => undef)");
is_deeply ([ $dbh->tables () ], [ $tbl ],	"tables");

ok ($dbh->do ("drop table $tbl"),		"drop table");

ok ($dbh->disconnect,				"disconnect");
undef $dbh;

ok (rmdir $dir,					"no files left");

done_testing ();