Permalink
Browse files

expand tests, checking the image file

  • Loading branch information...
1 parent 7e1d98d commit 2cf8cfbf24d12d4f1832a63942d63f37866320aa @rbuels rbuels committed Apr 13, 2011
Showing with 66 additions and 48 deletions.
  1. +66 −48 t/basics.t
View
@@ -11,24 +11,71 @@ use IO::String;
use Bio::GMOD::Blast::Graph;
-my $tempdir = File::Temp->newdir;
-
-my $report = catfile(qw( t data blast_report.blast ));
-my $image_name = 'foo.png';
-my $graph = Bio::GMOD::Blast::Graph->new(
- -outputfile => $report,
- -dstDir => "$tempdir",
- -dstURL => '/fake/url/',
- -imgName => $image_name,
- );
-
-isa_ok( $graph, 'Bio::GMOD::Blast::Graph' );
-
-my ( $stdout, $stderr ) = capture {
- $graph->showGraph;
-};
-
-like( $stdout, qr/$_/, "graph output has $_" )
+{
+ my $tempdir = File::Temp->newdir;
+
+ my $report = catfile(qw( t data blast_report.blast ));
+ my $image_name = 'foo.png';
+ my $image_path = catfile( $tempdir, $image_name );
+ my $graph = Bio::GMOD::Blast::Graph->new(
+ -outputfile => $report,
+ -dstDir => "$tempdir/",
+ -dstURL => '/fake/url/',
+ -imgName => $image_name,
+ );
+
+ isa_ok( $graph, 'Bio::GMOD::Blast::Graph' );
+ my ( $stdout, $stderr ) = capture {
+ $graph->showGraph;
+ };
+
+ ok( -f $image_path, 'temp image was written' );
+ system 'display', $image_path if $ENV{SHOW_IMAGES};
+
+
+ is( $stderr, '', 'no stderr' );
+
+ like( $stdout, qr/$_/, "graph output has $_" )
+ for (
+ $image_name,
+ qw(
+ SGN-U578206
+ SL2.40ch06
+ SGN-U580132
+ SGN-U578259
+ SL2.40ch12
+ ),
+ );
+}
+
+{
+ # do it again, this time writing to an external FH
+ my $tempdir = File::Temp->newdir;
+
+ my $report = catfile(qw( t data blast_report.blast ));
+ my $image_name = 'foo.png';
+ my $image_path = catfile( $tempdir, $image_name );
+
+ my $test_str;
+ my $graph = Bio::GMOD::Blast::Graph->new(
+ -outputfile => $report,
+ -dstDir => "$tempdir",
+ -dstURL => '/fake/url/',
+ -imgName => $image_name,
+ -fh => IO::String->new( \$test_str ),
+ );
+
+ my ( $out, $err ) = capture {
+ $graph->showGraph;
+ };
+ is( $out, '', 'no stdout' );
+ is( $err, '', 'no stderr' );
+
+ ok( -f $image_path, 'temp image was written' );
+ system 'display', $image_path if $ENV{SHOW_IMAGES};
+
+
+ like( $test_str, qr/$_/, "graph output has $_" )
for (
$image_name,
qw(
@@ -40,36 +87,7 @@ like( $stdout, qr/$_/, "graph output has $_" )
),
);
-my $test_str;
-
-# do it again, this time writing to an external FH
-$graph = Bio::GMOD::Blast::Graph->new(
- -outputfile => $report,
- -dstDir => "$tempdir",
- -dstURL => '/fake/url/',
- -imgName => $image_name,
- -fh => IO::String->new( \$test_str ),
- );
-
-my ( $out, $err ) = capture {
- $graph->showGraph;
-};
-is( $out, '', 'no stdout' );
-is( $err, '', 'no stderr' );
-
-like( $test_str, qr/$_/, "graph output has $_" )
- for (
- $image_name,
- qw(
- SGN-U578206
- SL2.40ch06
- SGN-U580132
- SGN-U578259
- SL2.40ch12
- ),
- );
-
-
+}
done_testing;

0 comments on commit 2cf8cfb

Please sign in to comment.