6 use Test::SQL::Translator qw(maybe_plan);
10 use SQL::Translator::Schema::Constants;
14 'SQL::Translator::Parser::SQLite');
16 SQL::Translator::Parser::SQLite->import('parse');
18 my $file = "$Bin/data/sqlite/create.sql";
22 open my $fh, "<$file" or die "Can't read file '$file': $!\n";
24 my $t = SQL::Translator->new;
27 my $schema = $t->schema;
29 my @tables = $schema->get_tables;
30 is( scalar @tables, 2, 'Parsed two tables' );
32 my $t1 = shift @tables;
33 is( $t1->name, 'person', "'Person' table" );
35 my $t2 = shift @tables;
36 is( $t2->name, 'pet', "'Pet' table" );
38 my @constraints = $t2->get_constraints;
39 is( scalar @constraints, 3, '3 constraints on pet' );
41 my $c1 = pop @constraints;
42 is( $c1->type, 'FOREIGN KEY', 'FK constraint' );
43 is( $c1->reference_table, 'person', 'References person table' );
44 is( join(',', $c1->reference_fields), 'person_id',
45 'References person_id field' );
47 my @views = $schema->get_views;
48 is( scalar @views, 1, 'Parsed one views' );
50 my @triggers = $schema->get_triggers;
51 is( scalar @triggers, 1, 'Parsed one triggers' );