Update tests to use maybe_plan.
[dbsrgits/SQL-Translator.git] / t / 04file,fh,string.t
CommitLineData
0494e672 1#!/usr/bin/perl
2# vim: set ft=perl:
3#
4# This tests that the same file can be passed in using a filename,
5# a filehandle, and a string, and return identical results. There's
6# a lot of setup here, because we have to emulate the various ways
7# that $tr->translate might be called: with a string (filename),
8# with a filehandle (IO::File, FileHandle, or \*FOO), and with a
9# scalar reference (data in a string).
10#
11
12use strict;
13
14use IO::File;
307d9560 15use Storable 'freeze';
0494e672 16use SQL::Translator;
40e47dd5 17use Test::More tests => 3;
30df963a 18
0494e672 19# The filename, holder for all the data, and the filehandle
20my $datafile = "t/data/mysql/Apache-Session-MySQL.sql";
21my $data;
22my $fh = IO::File->new($datafile);
23
307d9560 24my ($v1, $v2);
25{
26 my $tr = SQL::Translator->new;
27 # Pass filename: simplest way
28 $tr->translate($datafile);
29 $v1 = freeze( $tr->schema );
30}
0494e672 31
307d9560 32{
33 my $tr = SQL::Translator->new;
34 # Pass string reference
35 read($fh, $data, -s $datafile);
36 $tr->translate(\$data);
37 $v2 = freeze( $tr->schema );
38}
0494e672 39
307d9560 40ok(length $v1, "passing string (filename) works");
41ok(length $v2, "passing string as SCALAR reference");
42is($v1, $v2, "from file == from string");