Commit | Line | Data |
5fcc85af |
1 | #!/usr/bin/perl |
2 | # vim: set ft=perl: |
3 | |
4 | use strict; |
5fcc85af |
5 | use Test::More 'no_plan'; #tests => 180; |
153b2e77 |
6 | use FindBin qw/$Bin/; |
7 | |
5fcc85af |
8 | use SQL::Translator; |
153b2e77 |
9 | use SQL::Translator::Parser::SQLite 'parse'; |
5fcc85af |
10 | use SQL::Translator::Schema::Constants; |
11 | |
153b2e77 |
12 | my $file = "$Bin/data/sqlite/create.sql"; |
13 | |
5fcc85af |
14 | { |
153b2e77 |
15 | local $/; |
16 | open my $fh, "<$file" or die "Can't read file '$file': $!\n"; |
17 | my $data = <$fh>; |
5fcc85af |
18 | my $t = SQL::Translator->new; |
153b2e77 |
19 | parse($t, $data); |
20 | |
21 | my $schema = $t->schema; |
22 | |
23 | my @tables = $schema->get_tables; |
24 | is( scalar @tables, 2, 'Parsed two tables' ); |
25 | |
26 | my $t1 = shift @tables; |
27 | is( $t1->name, 'person', "'Person' table" ); |
28 | |
29 | my $t2 = shift @tables; |
30 | is( $t2->name, 'pet', "'Pet' table" ); |
31 | |
32 | my @views = $schema->get_views; |
33 | is( scalar @views, 1, 'Parsed one views' ); |
34 | |
35 | my @triggers = $schema->get_triggers; |
36 | is( scalar @triggers, 1, 'Parsed one triggers' ); |
5fcc85af |
37 | } |