X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei-import-nntp.t;h=eb1ae312143f2cfffafbbbf2e0fc5890b68cb00e;hb=refs%2Fheads%2Fmaster;hp=df0594d43c6748e460975a3a38854c6c722f6d9c;hpb=41c3eed65eb03256b0916cfdbf43723e070a633a;p=public-inbox.git diff --git a/t/lei-import-nntp.t b/t/lei-import-nntp.t index df0594d4..eb1ae312 100644 --- a/t/lei-import-nntp.t +++ b/t/lei-import-nntp.t @@ -25,6 +25,11 @@ test_lei({ tmpdir => $tmpdir }, sub { is(ref(json_utf8->decode($lei_out)), 'ARRAY', 'ls-mail-source JSON'); lei_ok('import', $url); + lei_ok "lcat", "nntp://$host_port/testmessage\@example.com"; + my $local = $lei_out; + lei_ok "lcat", "nntp://example.com/testmessage\@example.com"; + my $remote = $lei_out; + is($local, $remote, 'Message-ID used even from unknown host'); lei_ok(qw(q z:1..)); $out = json_utf8->decode($lei_out); ok(scalar(@$out) > 1, 'got imported messages'); @@ -49,6 +54,20 @@ test_lei({ tmpdir => $tmpdir }, sub { my $end = $high - 1; lei_ok qw(import), "$url/$high"; + lei_ok('inspect', $url); is_xdeeply(json_utf8->decode($lei_out), { + $url => { 'article.count' => 1, + 'article.min' => $high, + 'article.max' => $high, } + }, 'inspect output for URL after single message') or diag $lei_out; + lei_ok('inspect', "$url/$high"); + my $x = json_utf8->decode($lei_out); + like($x->{$url}->{$high}, qr/\A[a-f0-9]{40,}\z/, 'inspect shows blob'); + lei_ok qw(lcat -f json), "$url/$high"; + my $lcat = json_utf8->decode($lei_out); + is($lcat->[1], undef, 'only one result for lcat'); + is($lcat->[0]->{blob}, $x->{$url}->{$high}, + 'lcat showed correct blob'); + lei_ok 'ls-mail-sync'; is($lei_out, "$url\n", 'article number not stored as folder'); lei_ok qw(q z:0..); my $one = json_utf8->decode($lei_out); @@ -57,6 +76,31 @@ test_lei({ tmpdir => $tmpdir }, sub { local $ENV{HOME} = "$tmpdir/h3"; lei_ok qw(import), "$url/$low-$end"; + lei_ok('inspect', $url); is_xdeeply(json_utf8->decode($lei_out), { + $url => { 'article.count' => $end - $low + 1, + 'article.min' => $low, + 'article.max' => $end, } + }, 'inspect output for URL after range') or diag $lei_out; + lei_ok('inspect', "$url/$low-$end"); + $x = json_utf8->decode($lei_out); + is_deeply([ ($low..$end) ], [ sort { $a <=> $b } keys %{$x->{$url}} ], + 'inspect range shows range'); + is(scalar(grep(/\A[a-f0-9]{40,}\z/, values %{$x->{$url}})), + $end - $low + 1, 'all values are git blobs'); + + lei_ok qw(lcat -f json), "$url/$low"; + $lcat = json_utf8->decode($lei_out); + is($lcat->[1], undef, 'only one result for lcat'); + is($lcat->[0]->{blob}, $x->{$url}->{$low}, + 'lcat showed correct blob'); + lei_ok qw(lcat -f json), "$url/$low-$end"; + $lcat = json_utf8->decode($lei_out); + pop @$lcat; + for ($low..$end) { + my $tip = shift @$lcat; + is($x->{$url}->{$_}, $tip->{blob}, "blob matches art #$_"); + } + lei_ok 'ls-mail-sync'; is($lei_out, "$url\n", 'article range not stored as folder'); lei_ok qw(q z:0..); my $start = json_utf8->decode($lei_out);