public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob 2d3afd82ef53e7d86b218b1d89c83a4a805298ed 1937 bytes (raw)
$ git show HEAD:t/lei-up.t	# shows this blob on the CLI

 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
54
 
#!perl -w
# Copyright all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict; use v5.10.1; use PublicInbox::TestCommon;
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
test_lei(sub {
	my ($ro_home, $cfg_path) = setup_public_inboxes;
	my $home = $ENV{HOME};
	my $qp = eml_load('t/plack-qp.eml');
	my $s = $qp->as_string;
	lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
	lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/a.mbox.gz";
	lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/b.mbox.gz";
	lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/a";
	lei_ok qw(q z:0.. -f mboxcl2 -o), "$home/b";
	my $uc;
	for my $x (qw(a b)) {
		gunzip("$home/$x.mbox.gz" => \$uc, MultiStream => 1) or
				xbail "gunzip $GunzipError";
		ok(index($uc, $qp->body_raw) >= 0,
			"original mail in $x.mbox.gz") or diag $uc;
		open my $fh, '<', "$home/$x" or xbail $!;
		$uc = do { local $/; <$fh> } // xbail $!;
		ok(index($uc, $qp->body_raw) >= 0,
			"original mail in uncompressed $x") or diag $uc;
	}
	lei_ok qw(ls-search);
	$s = eml_load('t/utf8.eml')->as_string;
	lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
	lei_ok qw(up --all=local);

	gunzip("$home/a.mbox.gz" => \$uc, MultiStream => 1) or
		 xbail "gunzip $GunzipError";

	open my $fh, '<', "$home/a" or xbail "open: $!";
	my $exp = do { local $/; <$fh> };
	is($uc, $exp, 'compressed and uncompressed match (a.gz)');
	like($exp, qr/testmessage\@example.com/, '2nd message added');

	undef $uc;
	gunzip("$home/b.mbox.gz" => \$uc, MultiStream => 1) or
		 xbail "gunzip $GunzipError";
	is($uc, $exp, 'compressed and uncompressed match (b.gz)');

	open $fh, '<', "$home/b" or xbail "open: $!";
	$uc = do { local $/; <$fh> };
	is($uc, $exp, 'uncompressed both match');

	lei_ok [ qw(up -q), "$home/b", "--mua=touch $home/c" ],
		undef, { run_mode => 0 };
	ok(-f "$home/c", '--mua works with single output');
});

done_testing;

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git