X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F38-filter-names.t;h=4edd79343778395eed3ad3f03b439256bc8c690a;hb=HEAD;hp=ab791c6b2b636ae8c7f035df084776804dd9cfec;hpb=6cedfc23b6ba0390722dfeb2e7854b4ea36ae12b;p=dbsrgits%2FSQL-Translator.git diff --git a/t/38-filter-names.t b/t/38-filter-names.t index ab791c6..4edd793 100644 --- a/t/38-filter-names.t +++ b/t/38-filter-names.t @@ -4,31 +4,6 @@ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' -# SQL::Translator::Filter::HelloWorld - Test filter in a package -#============================================================================= -package SQL::Translator::Filter::HelloWorld; - -use strict; -use vars qw/$VERSION/; -$VERSION=0.1; - -sub filter { - my ($schema,$args) = (shift,shift); - - my $greeting = $args->{greeting} || "Hello"; - $schema->add_table( - name => "HelloWorld", - ); -} - -# Hack to allow sqlt to see our module as it wasn't loaded from a .pm -$INC{'SQL/Translator/Filter/HelloWorld.pm'} - = 'lib/SQL/Translator/Filter/HelloWorld.pm'; - -#============================================================================= - -package main; - use strict; use Test::More; use Test::Exception; @@ -53,26 +28,16 @@ schema: name: first_name }; -# helloworld: -# comments: '' -# constraints: [] -# fields: {} -# indices: [] -# name: HelloWorld -# options: [] -# order: 2 my $ans_yaml = qq{--- schema: procedures: {} tables: person: - comments: '' constraints: [] fields: First_name: data_type: foovar default_value: ~ - extra: {} is_nullable: 1 is_primary_key: 0 is_unique: 0 @@ -96,10 +61,10 @@ translator: producer_type: SQL::Translator::Producer::YAML show_warnings: 1 trace: 0 - version: 0.07 + version: SUPPRESSED }; -# Parse the test XML schema +# Parse the test schema my $obj; $obj = SQL::Translator->new( debug => 0, @@ -109,7 +74,7 @@ $obj = SQL::Translator->new( data => $in_yaml, filters => [ # Filter from SQL::Translator::Filter::* - [ 'Names', { + [ 'Names', { tables => 'lc', fields => 'ucfirst', } ], @@ -117,18 +82,11 @@ $obj = SQL::Translator->new( ) or die "Failed to create translator object: ".SQL::Translator->error; -#sub translate_ok { -# my ($sqlt,$ans_yaml,$name) = @_; -# $name ||= ""; -# -# my $out = eval { $sqlt->translate }; -# fail( $sqlt->error ) if $sqlt->error; -# fail( "No output" ) unless $out; -# eq_or_diff $out, $ans_yaml ,"Translated $name"; -#} - my $out; lives_ok { $out = $obj->translate; } "Translate ran"; is $obj->error, '' ,"No errors"; ok $out ne "" ,"Produced something!"; +# Somewhat hackishly modify the yaml with a regex to avoid +# failing randomly on every change of version. +$out =~ s/version: .*/version: SUPPRESSED/; eq_or_diff $out, $ans_yaml ,"Output looks right";