Added test number.
[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"' );
24is( $f1->data_type, 'VARCHAR', 'Data type is "VARCHAR"' );
25is( $f1->size, 255, 'Size is "255"' );
26is( $f1->is_primary_key, 1, 'Field is PK' );
27
28my $f2 = shift @fields;
29is( $f2->name, 'text', 'Second field name is "text"' );
30is( $f2->data_type, 'VARCHAR', 'Data type is "VARCHAR"' );
31is( $f2->size, 255, 'Size is "255"' );
32is( $f2->is_primary_key, 0, 'Field is not PK' );
33
34my $f3 = shift @fields;
35is( $f3->name, 'number', 'Third field name is "number"' );
36is( $f3->data_type, 'VARCHAR', 'Data type is "VARCHAR"' );
37is( $f3->size, 255, 'Size is "255"' );
38is( $f3->is_primary_key, 0, 'Field is not PK' );
39
40my $f4 = shift @fields;
41is( $f4->name, 'math', 'Fourth field name is "math"' );
42is( $f4->data_type, 'VARCHAR', 'Data type is "VARCHAR"' );
43is( $f4->size, 255, 'Size is "255"' );
44is( $f4->is_primary_key, 0, 'Field is not PK' );
45
46my $f5 = shift @fields;
47is( $f5->name, 'bitmap', 'Fifth field name is "bitmap"' );
48is( $f5->data_type, 'VARCHAR', 'Data type is "VARCHAR"' );
49is( $f5->size, 255, 'Size is "255"' );
50is( $f5->is_primary_key, 0, 'Field is not PK' );
51
52my $f6 = shift @fields;
53is( $f6->name, 'today', 'Sixth field name is "today"' );
54is( $f6->data_type, 'VARCHAR', 'Data type is "VARCHAR"' );
55is( $f6->size, 255, 'Size is "255"' );
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"' );
61is( $f7->data_type, 'VARCHAR', 'Data type is "VARCHAR"' );
62is( $f7->size, 255, 'Size is "255"' );
63is( $f7->is_primary_key, 0, 'Field is not PK' );