From: Darren Chamberlain Date: Tue, 8 Apr 2003 12:57:28 +0000 (+0000) Subject: Moving tests to Test::More X-Git-Tag: v0.02~197 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=37ac104aeb2567529faa74b5e6402e3a6a55e399;p=dbsrgits%2FSQL-Translator.git Moving tests to Test::More --- diff --git a/t/03mysql-to-oracle.t b/t/03mysql-to-oracle.t index 6eb3279..f4e22a1 100644 --- a/t/03mysql-to-oracle.t +++ b/t/03mysql-to-oracle.t @@ -1,7 +1,9 @@ #!/usr/local/bin/perl # vim: set ft=perl: -BEGIN { print "1..1\n" } +use Test::More; + +plan tests => 1; my $create = q| CREATE TABLE random ( @@ -14,14 +16,9 @@ CREATE TABLE random ( use SQL::Translator; use Data::Dumper; -$SQL::Translator::DEBUG = 0; - my $tr = SQL::Translator->new(parser => "MySQL", producer => "Oracle" - #producer => "SQL::Translator::Producer::Oracle::translate" - #producer => sub { Dumper($_[1]) } ); -print "not " unless ($tr->translate(\$create)); -print "ok 1 # pointless test -- plz fix me!\n"; +ok($tr->translate(\$create)); diff --git a/t/04file,fh,string.t b/t/04file,fh,string.t index 7674f4e..658782e 100644 --- a/t/04file,fh,string.t +++ b/t/04file,fh,string.t @@ -13,11 +13,9 @@ use strict; use IO::File; use SQL::Translator; +use Test::More; -# How many tests -BEGIN { print "1..3\n"; } - -$SQL::Translator::DEBUG = 0; +plan tests => 3; # Our object; uses the default parser and producer my $tr = SQL::Translator->new; @@ -29,18 +27,11 @@ my $fh = IO::File->new($datafile); # Pass filename: simplest way my $translated_datafile = $tr->translate($datafile); -#warn "Data from filename method is\n$translated_datafile\n\n\n"; # Pass string reference read($fh, $data, -s $datafile); my $translated_data = $tr->translate(\$data); -#warn "Data from string is\n$translated_data\n\n\n"; - -print "not " unless length $translated_datafile; -print "ok 1 # passing string (filename) works\n"; - -print "not " unless length $translated_data; -print "ok 2 # passing string as SCALAR reference\n"; -print "not " unless ($translated_datafile eq $translated_data); -print "ok 3 # from file == from string\n"; +ok(length $translated_datafile, "passing string (filename) works"); +ok(length $translated_data, "passing string as SCALAR reference"); +is($translated_datafile, $translated_data, "from file == from string"); diff --git a/t/06xsv.t b/t/06xsv.t index 39fc6fe..10aa09a 100644 --- a/t/06xsv.t +++ b/t/06xsv.t @@ -6,8 +6,9 @@ use strict; use SQL::Translator; use SQL::Translator::Parser::xSV qw(parse); +use Test::More; -$SQL::Translator::DEBUG = 0; +plan tests => 10; my $tr = SQL::Translator->new; my $data = q|One, Two, Three, Four, Five @@ -15,44 +16,36 @@ I, Am, Some, Data, Yo And, So, am, I, "you crazy, crazy bastard" );|; -BEGIN { print "1..10\n"; } - my $val = parse($tr, $data); # $val holds the processed data structure. # The data structure should have one key: -print "not " if (scalar keys %{$val} != 1); -print "ok 1\n"; +is(scalar keys %{$val}, 1, "One table..."); # The data structure should have a single key, named sessions -print "not " unless (defined $val->{'table1'}); -print qq(ok 2 # has a key named "table1"\n); +ok(defined $val->{'table1'} => "...named 'table1'"); # $val->{'table1'} should have a single index (since we haven't # defined an index, but have defined a primary key) my $indices = $val->{'table1'}->{'indices'}; -print "not " unless (scalar @{$indices} == 1); -print "ok 3 # correct index number\n"; +is(scalar @{$indices}, 1, "correct index number"); -print "not " unless ($indices->[0]->{'type'} eq 'primary_key'); -print "ok 4 # correct index type\n"; -print "not " unless ($indices->[0]->{'fields'}->[0] eq 'One'); -print "ok 5 # correct index name\n"; +is($indices->[0]->{'type'}, 'primary_key', "correct index type"); +is($indices->[0]->{'fields'}->[0], 'One', "correct index name"); # $val->{'table1'} should have two fields, id and a_sessionn my $fields = $val->{'table1'}->{'fields'}; -print "not " unless (scalar keys %{$fields} == 5); -print "ok 6 # correct number of fields (5)\n"; +is(scalar keys %{$fields} => 5 => "5 fields in %fields"); -print "not " unless ($fields->{'One'}->{'data_type'} eq 'char'); -print "ok 7 # correct field type: One (char)\n"; +is($fields->{'One'}->{'data_type'}, 'char', + "\$fields->{'One'}->{'data_type'} == 'char'"); -print "not " unless ($fields->{'One'}->{'is_primary_key'} == 1); -print "ok 8 # correct key identification (One == key)\n"; +is($fields->{'One'}->{'is_primary_key'} => 1, + "\$fields->{'One'}->{'is_primary_key'} == 1"); -print "not " if (defined $fields->{'Two'}->{'is_primary_key'}); -print "ok 9 # correct key identification (Two != key)\n"; +ok(! defined $fields->{'Two'}->{'is_primary_key'}, + "\$fields->{'Two'}->{'is_primary_key'} == 0"); # Test that the order is being maintained by the internal order # data element @@ -60,5 +53,4 @@ my @order = sort { $fields->{$a}->{'order'} <=> $fields->{$b}->{'order'} } keys %{$fields}; -print "not " unless ($order[0] eq 'One' && $order[4] eq 'Five'); -print "ok 10 # ordering of fields\n"; +ok($order[0] eq 'One' && $order[4] eq 'Five', "Ordering OK");