2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # unit test for "lei lcat" internals, see t/lei-lcat.t for functional test
8 use_ok 'PublicInbox::LeiLcat';
9 my $cb = \&PublicInbox::LeiLcat::extract_1;
11 my ($txt, $exp, $t) = @_;
13 is($cb->($lei, $txt), $exp, $txt);
14 ($t ? is_deeply($lei, { mset_opt => { threads => 1 } }, "-t $exp")
15 : is_deeply($lei, {}, "no -t for $exp")) or diag explain($lei);
18 for my $txt (qw(https://example.com/inbox/foo@bar/
19 https://example.com/inbox/foo@bar
20 https://example.com/inbox/foo@bar/raw
24 <https://example.com/inbox/foo@bar>
25 <https://example.com/inbox/foo@bar/raw>
26 <https://example.com/inbox/foo@bar/>
27 <nntp://example.com/foo@bar>)) {
28 $ck->($txt, 'mid:foo@bar');
31 for my $txt (qw(https://example.com/inbox/foo@bar/T/
32 https://example.com/inbox/foo@bar/t/
33 https://example.com/inbox/foo@bar/t.mbox.gz
34 <https://example.com/inbox/foo@bar/t.atom>
35 <https://example.com/inbox/foo@bar/t/>)) {
36 $ck->($txt, 'mid:foo@bar', '-t');
39 $ck->('https://example.com/x/foobar/T/', 'mid:foobar', '-t');
40 $ck->('https://example.com/x/foobar/raw', 'mid:foobar');
41 is($cb->(my $lei = {}, 'asdf'), undef, 'no Message-ID');
42 is($cb->($lei = {}, 'm:x'), 'm:x', 'bare m: accepted');