File: Catmandu-Exporter-HTML.t

package info (click to toggle)
libcatmandu-html-perl 0.02%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 305; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 955 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!perl

use strict;
use warnings;
use Test::More;
use Catmandu;
use Catmandu::Importer::HTML;
use Digest::MD5 qw(md5_hex);

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Exporter::HTML';
    use_ok $pkg;
};

require_ok $pkg;

my $html = '';
my $exporter = $pkg->new(file => \$html);

isa_ok $exporter, $pkg;

my $importer = Catmandu::Importer::HTML->new(file => 't/muse.html');
my $record  = $importer->first;

ok $exporter->add($record);

ok $exporter->commit;

utf8::encode($html);

like $html , qr{^<html><body>};

my $digest = md5_hex($html);

is $digest , '885da867f959a433aeefc7c370d4437d';

$exporter = $pkg->new(file => 't/muse.html.out');
$importer = Catmandu::Importer::HTML->new(file => 't/muse.html');

$exporter->add_many($importer);
$exporter->commit;

my $fh;
open $fh , 't/muse.html.out';
$digest = Digest::MD5->new->addfile($fh)->hexdigest;
is $digest , '885da867f959a433aeefc7c370d4437d';
close($fh);

unlink 't/muse.html.out';

done_testing;