]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/common.perl
remove XML::Atom::SimpleFeed dependency
[public-inbox.git] / t / common.perl
diff --git a/t/common.perl b/t/common.perl
new file mode 100644 (file)
index 0000000..a3585bf
--- /dev/null
@@ -0,0 +1,16 @@
+require IO::File;
+use POSIX qw/dup/;
+
+sub stream_to_string {
+       my ($cb) = @_;
+       my $headers;
+       my $io = IO::File->new_tmpfile;
+       my $dup = dup($io->fileno);
+       my $response = sub { $headers = \@_, $io };
+       $cb->($response);
+       $io = IO::File->new;
+       $io->fdopen($dup, 'r+');
+       $io->seek(0, 0);
+       $io->read(my $str, ($io->stat)[7]);
+       $str;
+}