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