X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F15oracle-parser.t;h=4660857db47306d5afe6c235ed3afaa858004603;hb=ec791002ba1fed6772d86a89de64ff65c1be3545;hp=f969a25b2d38c302d074d323ba0c24dce9ff970f;hpb=75484db3617639c880d0a89734be501e92655738;p=dbsrgits%2FSQL-Translator.git diff --git a/t/15oracle-parser.t b/t/15oracle-parser.t index f969a25..4660857 100644 --- a/t/15oracle-parser.t +++ b/t/15oracle-parser.t @@ -1,10 +1,14 @@ #!/usr/bin/perl +# vim: set ft=perl: use strict; -use Test::More 'no_plan'; #tests => 105; +use Test::More; use SQL::Translator; use SQL::Translator::Schema::Constants; -use SQL::Translator::Parser::Oracle qw(parse); +use Test::SQL::Translator qw(maybe_plan); + +maybe_plan(76, 'SQL::Translator::Parser::Oracle'); +SQL::Translator::Parser::Oracle->import('parse'); my $t = SQL::Translator->new( trace => 0 ); my $sql = q[ @@ -19,6 +23,7 @@ my $sql = q[ comment on column qtl_trait_category.qtl_trait_category_id is 'the primary key!'; + -- foo bar comment CREATE TABLE qtl_trait ( qtl_trait_id NUMBER(11) NOT NULL @@ -31,21 +36,24 @@ my $sql = q[ FOREIGN KEY ( qtl_trait_category_id ) REFERENCES qtl_trait_category ); + /* qtl table comment */ CREATE TABLE qtl ( + /* qtl_id comment */ qtl_id NUMBER(11) NOT NULL CONSTRAINT pk_qtl PRIMARY KEY, - qtl_accession_id VARCHAR2(20) NOT NULL, + qtl_accession_id VARCHAR2(20) NOT NULL /* accession comment */, published_symbol VARCHAR2(100), qtl_trait_id NUMBER(11) NOT NULL, linkage_group VARCHAR2(32) NOT NULL, start_position NUMBER(11,2) NOT NULL, stop_position NUMBER(11,2) NOT NULL, comments long, - UNIQUE ( qtl_accession_id ), FOREIGN KEY ( qtl_trait_id ) REFERENCES qtl_trait ); + CREATE UNIQUE INDEX qtl_accession ON qtl ( qtl_accession_id ); + CREATE TABLE qtl_trait_synonym ( qtl_trait_synonym_id NUMBER(11) NOT NULL @@ -62,9 +70,6 @@ $| = 1; my $data = parse( $t, $sql ); my $schema = $t->schema; -#use Data::Dumper; -#print Dumper($schema), "\n"; - isa_ok( $schema, 'SQL::Translator::Schema', 'Schema object' ); my @tables = $schema->get_tables; is( scalar @tables, 4, 'Found four tables' ); @@ -87,7 +92,7 @@ is( $f1->size, 11, 'Size is "11"' ); is( $f1->is_nullable, 0, 'Field cannot be null' ); is( $f1->default_value, undef, 'Default value is undefined' ); is( $f1->is_primary_key, 1, 'Field is PK' ); -is( $f1->comments, 'the primary key!', 'Comment = "the primary key!"' ); +is( join(',', $f1->comments), 'the primary key!', 'Comment = "the primary key!"' ); my $f2 = shift @t1_fields; is( $f2->name, 'trait_category', 'Second field is "trait_category"' ); @@ -120,6 +125,7 @@ is( join(',', $c2->fields), 'trait_category', # my $t2 = shift @tables; is( $t2->name, 'qtl_trait', 'Table "qtl_trait" exists' ); +is( $t2->comments, 'foo bar comment', 'Comment "foo bar" exists' ); my @t2_fields = $t2->get_fields; is( scalar @t2_fields, 4, '4 fields in table' ); @@ -201,6 +207,15 @@ is( scalar @t3_fields, 8, '8 fields in table' ); my @t3_constraints = $t3->get_constraints; is( scalar @t3_constraints, 3, '3 constraints on table' ); +is( $t3->comments, 'qtl table comment', 'Comment "qtl table comment" exists' ); + +my $t3_f1 = shift @t3_fields; +is( $t3_f1->comments, 'qtl_id comment', 'Comment "qtl_id comment" exists' ); + +my $t3_f2 = shift @t3_fields; +is( $t3_f2->comments, 'accession comment', + 'Comment "accession comment" exists' ); + # # qtl_trait_synonym #