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