From: Peter Rabbitson Date: Tue, 28 Apr 2009 08:14:59 +0000 (+0000) Subject: Translator/schema dependency test X-Git-Tag: v0.11008~163^2~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cbceab6ae9d955b2747b99ffe88242a98fd3510e;p=dbsrgits%2FSQL-Translator.git Translator/schema dependency test --- diff --git a/t/61translator_agnostic.t b/t/61translator_agnostic.t new file mode 100644 index 0000000..52c4678 --- /dev/null +++ b/t/61translator_agnostic.t @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use warnings; +use strict; +use Test::More qw/no_plan/; +use Test::Exception; +use FindBin qw/$Bin/; + +use SQL::Translator; + +# Producing a schema with a Translator different from the one the schema was +# generated should just work. After all the $schema object is just data. + + +my $base_file = "$Bin/data/xml/schema.xml"; +my $base_t = SQL::Translator->new; +$base_t->$_ (1) for qw/add_drop_table no_comments/; + +# create a base schema attached to $base_t +my $base_schema = $base_t->translate ( + parser => 'XML', + file => $base_file, +) or die $base_t->error; + +# now create a new translator and try to feed it the same schema +my $new_t = SQL::Translator->new; +$new_t->$_ (1) for qw/add_drop_table no_comments/; + +my $sql = $new_t->translate ( + data => $base_schema, + producer => 'SQLite' +); + +like ( + $sql, + qr/^\s*CREATE TABLE/m, #assume there is at least one create table statement + "Received some meaningful output from the producer", +);