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