blob: c9eabf07503f1cbf28a8f8be3e385f49c3cfd8cc [file] [log] [blame]
Akron85717512020-07-08 11:19:19 +02001use strict;
2use warnings;
3use Test::More;
4use File::Basename 'dirname';
5use File::Spec::Functions qw/catfile/;
6use File::Temp ':POSIX';
7use IO::Uncompress::Unzip;
8
9use FindBin;
10BEGIN {
11 unshift @INC, "$FindBin::Bin/../lib";
12};
13
14require_ok('KorAP::XML::TEI::Zipper');
15
16my $data;
17my $outzip = tmpnam();
18
19my $zip = KorAP::XML::TEI::Zipper->new($outzip);
20
21ok($zip, 'Zipper initialized');
22
23ok($zip->new_stream('data/file1.txt')->print('hello'), 'Write to initial stream');
24ok($zip->new_stream('data/file2.txt')->print('world'), 'Write to appended stream');
25
26$zip->close;
27
28ok(-e $outzip, 'Zip exists');
29
30# Uncompress GOE/header.xml from zip file
31my $unzip = IO::Uncompress::Unzip->new($outzip, Name => 'data/file1.txt');
32
33$data .= $unzip->getline while !$unzip->eof;
34ok($unzip->close, 'Closed');
35
36is($data, 'hello', 'Data correct');
37
38
39# Uncompress GOE/header.xml from zip file
40$unzip = IO::Uncompress::Unzip->new($outzip, Name => 'data/file2.txt');
41
42$data = '';
43$data .= $unzip->getline while !$unzip->eof;
44ok($unzip->close, 'Closed');
45
46is($data, 'world', 'Data correct');
47
48done_testing;