Update tests to use maybe_plan.
[dbsrgits/SQL-Translator.git] / t / 18ttschema-producer.t
index a398f66..ab13c31 100644 (file)
@@ -4,11 +4,14 @@
 # Before `make install' is performed this script should be runnable with
 # `make test'. After `make install' it should work as `perl test.pl'
 
+use strict;
 use Test::More;
 use Test::Exception;
+use Test::SQL::Translator qw(maybe_plan);
 
 use Data::Dumper;
-BEGIN { our %opt; map { $opt{$_}=1 if s/^-// } @ARGV; }
+use vars '%opt';
+BEGIN { map { $opt{$_}=1 if s/^-// } @ARGV; }
 use constant DEBUG => (exists $opt{d} ? 1 : 0);
 local $SIG{__WARN__} = sub { diag "[warn] ", @_; };
 
@@ -17,27 +20,21 @@ use FindBin qw/$Bin/;
 # Testing 1,2,3,4...
 #=============================================================================
 
-eval { require Template; };
-if ($@ && $@ =~ m!locate Template.pm in!) {
-    plan skip_all => "You need Template Toolkit to run this test.";
-}
-eval { require Test::Differences; };
-if ($@ && $@ =~ m!locate Test/Differences.pm in!) {
-    plan skip_all => "You need Test::Differences for this test.";
+BEGIN {
+    maybe_plan(3, 'Template', 'Test::Differences')
 }
 use Test::Differences;
-plan tests => 3;
     
 use SQL::Translator;
 use SQL::Translator::Producer::TTSchema;
 
 # Parse the test XML schema
-our $obj;
+my $obj;
 $obj = SQL::Translator->new(
     debug          => DEBUG, #$opt{d},
     show_warnings  => 1,
     add_drop_table => 1,
-    from           => "SqlfXML",
+    from           => "XML-SQLFairy",
     filename       => "$Bin/data/xml/schema-basic.xml",
     to             => "TTSchema",
      producer_args  => {
@@ -45,12 +42,12 @@ $obj = SQL::Translator->new(
     },
 );
 my $out;
-lives_ok { $out = $obj->translate; }  "Produced template";
-ok $out ne ""                        ,"Output has some content";
+lives_ok { $out = $obj->translate; }  "Translate ran";
+ok $out ne ""                        ,"Produced something!";
 local $/ = undef; # slurp
 eq_or_diff $out, <DATA>              ,"Output looks right";
-# I'm sure if this diff is the best test, it is probaly too sensitive. But it
-# at least it will blow up if anything changes!
+# I'm not sure if this diff is the best test, it is probaly too sensitive. But 
+# it at least it will blow up if anything changes!
 
 print $out if DEBUG;
 #print "Debug:", Dumper($obj) if DEBUG;
@@ -153,6 +150,21 @@ Fields
         extra:                 
         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
+        extra:                 
+        table:                 Basic
+    
 
 Indices
     titleindex