File: app-pod2pandoc-meta.t

package info (click to toggle)
libpod-pandoc-perl 0.5.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 248 kB
  • sloc: perl: 587; makefile: 5
file content (39 lines) | stat: -rw-r--r-- 1,050 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
use strict;
use Test::More;
use Test::Exception;
use File::Temp qw(tempfile);
use App::pod2pandoc;
use Pandoc::Elements;

plan skip_all => 'these tests are for release candidate testing'
  unless $ENV{RELEASE_TESTING};

sub pod2meta {
    my ( $fh, $file ) = tempfile;
    pod2pandoc ['script/pod2pandoc'], {@_}, '-t' => 'json', '-o', $file;
    my $json = do { local ( @ARGV, $/ ) = $file; <> };
    pandoc_json($json)->metavalue;
}

my $expect = {
    file     => 'script/pod2pandoc',
    subtitle => 'convert Pod to Pandoc document model',
    title    => 'pod2pandoc'
};

is_deeply pod2meta(), $expect, 'no meta';

throws_ok { pod2meta( meta => 't/examples/missing.json' ) }
qr{^failed to open t/examples/missing\.json}, 'invalid meta';

$expect->{bool} = 0;
$expect->{map} = { list => [ 1, 2 ] };
is_deeply pod2meta( meta => 't/examples/metadata.json' ), $expect,
  'meta from json';

$expect->{bool} = 1;
$expect->{map}{list} = ['a string'];
is_deeply pod2meta( meta => 't/examples/metadata.yaml' ), $expect,
  'meta from YAML';

done_testing;