From 08d534c230a050406f9c08f721e6d30ca5a9d515 Mon Sep 17 00:00:00 2001 From: "Kevin L. Kane" Date: Tue, 4 Aug 2015 09:50:37 -0400 Subject: [PATCH] adding tests for setContentFile behavior --- t/basic.t | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/t/basic.t b/t/basic.t index 7877d61..0f42330 100644 --- a/t/basic.t +++ b/t/basic.t @@ -119,7 +119,31 @@ SKIP: { ok(scalar($client->responseHeaders()), 'Header names available'); ok( $client->responseHeader('Client-Response-Num'), 'Can pull a header'); + my $fn = "content_file_test"; + $client->setContentFile( $fn ); + $path = "/ok/" . time() . "/"; + $client->GET( $path ); + open( my $fh, "<", $fn ); + my $test; + while( my $data = <$fh> ) { + $test .= $data; + } + + is( $test, $path, "GET into ContentFile (filename) works" ); + `rm $fn`; + + $test = ""; + + my $callback = sub { + my ( $data, $resp, $prot ) = @_; + $test .= $data; + }; + $client->setContentFile( $callback ); + $client->GET( $path ); + is( $test, $path, "GET into ContentFile (callback) works" ); + + $client->setContentFile( undef ); }; warn "Tests died: $@" if $@;