Release commit for 1.62
[dbsrgits/SQL-Translator.git] / t / 18ttschema-producer.t
index c6efae0..3118da8 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w 
+#!/usr/bin/perl -w
 # vim:filetype=perl
 
 # Before `make install' is performed this script should be runnable with
@@ -16,16 +16,9 @@ use FindBin qw/$Bin/;
 #=============================================================================
 
 BEGIN {
-    eval {require Template;};
-
-    if ( $@ ) {
-        plan skip_all => 'Template not installed?'
-    }
-
-    maybe_plan(6, 
-        'XML::XPath', 
+    maybe_plan(6,
         'SQL::Translator::Parser::XML::SQLFairy',
-        'Template', 
+        'Template 2.20',
         'Test::Differences'
     );
 }
@@ -38,7 +31,7 @@ use SQL::Translator::Producer::TTSchema;
 {
     my $obj;
     $obj = SQL::Translator->new(
-        show_warnings  => 1,
+        show_warnings  => 0,
         from           => "XML-SQLFairy",
         filename       => "$Bin/data/xml/schema.xml",
         to             => "TTSchema",
@@ -53,8 +46,11 @@ use SQL::Translator::Producer::TTSchema;
     my $out;
     lives_ok { $out = $obj->translate; }  "Translate ran";
     ok $out ne ""                        ,"Produced something!";
-    local $/ = undef; # slurp
-    eq_or_diff $out, <DATA>              ,"Output looks right";
+    eq_or_diff
+      $out,
+      do { local (@ARGV, $/) = "$Bin/data/template/testresult_basic.txt"; <> },
+      "Output looks right"
+    ;
 }
 
 # Test passing of Template config
@@ -65,7 +61,7 @@ use SQL::Translator::Producer::TTSchema;
     [%- END %]};
     my $obj;
     $obj = SQL::Translator->new(
-        show_warnings  => 1,
+        show_warnings  => 0,
         from           => "XML-SQLFairy",
         filename       => "$Bin/data/xml/schema.xml",
         to             => "TTSchema",
@@ -89,227 +85,3 @@ use SQL::Translator::Producer::TTSchema;
     Table: Another}
     ,"Output looks right";
 }
-
-
-__DATA__
-Schema: 
-Database: 
-
-Foo: bar
-Hello: world
-
-Table: Basic
-==========================================================================
-
-Fields
-    id
-        data_type:             int
-        size:                  10
-        is_nullable:           0
-        default_value:         
-        is_primary_key:        1
-        is_unique:             0
-        is_auto_increment:     1
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 1
-        table:                 Basic
-    
-    title
-        data_type:             varchar
-        size:                  100
-        is_nullable:           0
-        default_value:         hello
-        is_primary_key:        0
-        is_unique:             0
-        is_auto_increment:     0
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 2
-        table:                 Basic
-    
-    description
-        data_type:             text
-        size:                  0
-        is_nullable:           1
-        default_value:         
-        is_primary_key:        0
-        is_unique:             0
-        is_auto_increment:     0
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 3
-        table:                 Basic
-    
-    email
-        data_type:             varchar
-        size:                  500
-        is_nullable:           1
-        default_value:         
-        is_primary_key:        0
-        is_unique:             1
-        is_auto_increment:     0
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 4
-        table:                 Basic
-    
-    explicitnulldef
-        data_type:             varchar
-        size:                  0
-        is_nullable:           1
-        default_value:         
-        is_primary_key:        0
-        is_unique:             0
-        is_auto_increment:     0
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 5
-        table:                 Basic
-    
-    explicitemptystring
-        data_type:             varchar
-        size:                  0
-        is_nullable:           1
-        default_value:         
-        is_primary_key:        0
-        is_unique:             0
-        is_auto_increment:     0
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 6
-        table:                 Basic
-    
-    emptytagdef
-        data_type:             varchar
-        size:                  0
-        is_nullable:           1
-        default_value:         
-        is_primary_key:        0
-        is_unique:             0
-        is_auto_increment:     0
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 7
-        table:                 Basic
-    
-    another_id
-        data_type:             int
-        size:                  10
-        is_nullable:           1
-        default_value:         2
-        is_primary_key:        0
-        is_unique:             0
-        is_auto_increment:     0
-        is_foreign_key:        1
-        foreign_key_reference: Another
-        is_valid:              1
-        order:                 8
-        table:                 Basic
-    
-    timest
-        data_type:             timestamp
-        size:                  0
-        is_nullable:           1
-        default_value:         
-        is_primary_key:        0
-        is_unique:             0
-        is_auto_increment:     0
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 9
-        table:                 Basic
-    
-
-Indices
-    titleindex
-        table:    Basic
-        fields:   title
-        type:     NORMAL
-        options:  
-        is_valid: 1
-    
-    
-Constraints
-    ?
-        type:             PRIMARY KEY
-        fields:           id
-        expression:       
-        match_type:       
-        reference_fields: 
-        reference_table:  
-        deferrable:       1
-        on_delete:        
-        on_update:        
-        options:          
-        is_valid:         1
-    
-    emailuniqueindex
-        type:             UNIQUE
-        fields:           email
-        expression:       
-        match_type:       
-        reference_fields: 
-        reference_table:  
-        deferrable:       1
-        on_delete:        
-        on_update:        
-        options:          
-        is_valid:         1
-    
-    ?
-        type:             FOREIGN KEY
-        fields:           another_id
-        expression:       
-        match_type:       
-        reference_fields: id
-        reference_table:  Another
-        deferrable:       1
-        on_delete:        
-        on_update:        
-        options:          
-        is_valid:         1
-    
-Table: Another
-==========================================================================
-
-Fields
-    id
-        data_type:             int
-        size:                  10
-        is_nullable:           0
-        default_value:         
-        is_primary_key:        1
-        is_unique:             0
-        is_auto_increment:     1
-        is_foreign_key:        0
-        foreign_key_reference: 
-        is_valid:              1
-        order:                 10
-        table:                 Another
-    
-
-Indices
-    
-Constraints
-    ?
-        type:             PRIMARY KEY
-        fields:           id
-        expression:       
-        match_type:       
-        reference_fields: 
-        reference_table:  
-        deferrable:       1
-        on_delete:        
-        on_update:        
-        options:          
-        is_valid:         1
-