Added list of constants exported to the docs.
[dbsrgits/SQL-Translator.git] / t / 10excel.t
CommitLineData
fc4e23d3 1#!/usr/bin/perl
2# vim: set ft=perl:
fc4e23d3 3
dd105736 4use Test::More tests => 31;
fc4e23d3 5use SQL::Translator;
b1a69c78 6use SQL::Translator::Parser::Excel 'parse';
7use SQL::Translator::Schema::Constants;
fc4e23d3 8
b1a69c78 9my $tr = SQL::Translator->new(parser => "Excel");
10my $t = $tr->translate(filename => "t/data/Excel/t.xls");
11my $schema = $tr->schema;
fc4e23d3 12
b1a69c78 13my @tables = $schema->get_tables;
14is( scalar @tables, 1, 'Parsed 1 table' );
ab0aa010 15
b1a69c78 16my $table = shift @tables;
17is( $table->name, 'Sheet1', 'Table name is "Sheet1"' );
ab0aa010 18
b1a69c78 19my @fields = $table->get_fields;
20is( scalar @fields, 7, 'Table has 7 fields' );
21
22my $f1 = shift @fields;
23is( $f1->name, 'ID', 'First field name is "ID"' );
71e9c5e4 24is( lc $f1->data_type, 'integer', 'Data type is "integer"' );
25is( $f1->size, 5, 'Size is "5"' );
b1a69c78 26is( $f1->is_primary_key, 1, 'Field is PK' );
27
28my $f2 = shift @fields;
29is( $f2->name, 'text', 'Second field name is "text"' );
71e9c5e4 30is( lc $f2->data_type, 'char', 'Data type is "char"' );
31is( $f2->size, 7, 'Size is "7"' );
b1a69c78 32is( $f2->is_primary_key, 0, 'Field is not PK' );
33
34my $f3 = shift @fields;
35is( $f3->name, 'number', 'Third field name is "number"' );
beb8e233 36is( lc $f3->data_type, 'integer', 'Data type is "integer"' );
37is( $f3->size, 1, 'Size is "1"' );
b1a69c78 38is( $f3->is_primary_key, 0, 'Field is not PK' );
39
40my $f4 = shift @fields;
41is( $f4->name, 'math', 'Fourth field name is "math"' );
beb8e233 42is( lc $f4->data_type, 'float', 'Data type is "float"' );
43is( $f4->size, '3,1', 'Size is "3,1"' );
b1a69c78 44is( $f4->is_primary_key, 0, 'Field is not PK' );
45
46my $f5 = shift @fields;
47is( $f5->name, 'bitmap', 'Fifth field name is "bitmap"' );
cc558ea2 48is( lc $f5->data_type, 'char', 'Data type is "char"' );
c77202c4 49is( $f5->size, 1, 'Size is "1"' );
b1a69c78 50is( $f5->is_primary_key, 0, 'Field is not PK' );
51
52my $f6 = shift @fields;
53is( $f6->name, 'today', 'Sixth field name is "today"' );
71e9c5e4 54is( lc $f6->data_type, 'char', 'Data type is "CHAR"' );
55is( $f6->size, 10, 'Size is "10"' );
b1a69c78 56is( $f6->is_primary_key, 0, 'Field is not PK' );
57
58my $f7 = shift @fields;
59is( $f7->name, 'silly_field_with_random_characters',
60 'Seventh field name is "silly_field_with_random_characters"' );
71e9c5e4 61is( lc $f7->data_type, 'char', 'Data type is "CHAR"' );
62is( $f7->size, 11, 'Size is "11"' );
b1a69c78 63is( $f7->is_primary_key, 0, 'Field is not PK' );