Create Zip-Factory for simpler handling of Zip streams
Change-Id: I66fb1e980437f9b931d71b8bc9fde54bda2aee6f
diff --git a/t/script.t b/t/script.t
index da45633..3ac91d1 100644
--- a/t/script.t
+++ b/t/script.t
@@ -38,6 +38,8 @@
'Processing'
);
+ok(-e $outzip, "File $outzip exists");
+
# Uncompress GOE/header.xml from zip file
my $zip = IO::Uncompress::Unzip->new($outzip, Name => 'GOE/header.xml');
diff --git a/t/zipper.t b/t/zipper.t
new file mode 100644
index 0000000..c9eabf0
--- /dev/null
+++ b/t/zipper.t
@@ -0,0 +1,48 @@
+use strict;
+use warnings;
+use Test::More;
+use File::Basename 'dirname';
+use File::Spec::Functions qw/catfile/;
+use File::Temp ':POSIX';
+use IO::Uncompress::Unzip;
+
+use FindBin;
+BEGIN {
+ unshift @INC, "$FindBin::Bin/../lib";
+};
+
+require_ok('KorAP::XML::TEI::Zipper');
+
+my $data;
+my $outzip = tmpnam();
+
+my $zip = KorAP::XML::TEI::Zipper->new($outzip);
+
+ok($zip, 'Zipper initialized');
+
+ok($zip->new_stream('data/file1.txt')->print('hello'), 'Write to initial stream');
+ok($zip->new_stream('data/file2.txt')->print('world'), 'Write to appended stream');
+
+$zip->close;
+
+ok(-e $outzip, 'Zip exists');
+
+# Uncompress GOE/header.xml from zip file
+my $unzip = IO::Uncompress::Unzip->new($outzip, Name => 'data/file1.txt');
+
+$data .= $unzip->getline while !$unzip->eof;
+ok($unzip->close, 'Closed');
+
+is($data, 'hello', 'Data correct');
+
+
+# Uncompress GOE/header.xml from zip file
+$unzip = IO::Uncompress::Unzip->new($outzip, Name => 'data/file2.txt');
+
+$data = '';
+$data .= $unzip->getline while !$unzip->eof;
+ok($unzip->close, 'Closed');
+
+is($data, 'world', 'Data correct');
+
+done_testing;