about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-05-28 22:37:21 +0000
committerEric Wong <e@80x24.org>2021-05-28 22:38:43 +0000
commite3b920c4fdf4fb981306cc3fc832bdd367ccc922 (patch)
tree2ed199def390bd48faa48f0e073ae08b473ebe74 /t
parent5944277a4dc986f9adf9ba69a1e6e44899ad98c1 (diff)
downloadpublic-inbox-e3b920c4fdf4fb981306cc3fc832bdd367ccc922.tar.gz
This allows "lei-managed pseudo mailing lists" as described
by Konstantin.

Alternates use is optional and can be enables via --shared.

This doesn't manage or edit ~/.public-inbox/config; presumably
there'll need to be some tweaking of search parameters before
finalizing and making the inbox publicly accessible via HTTP/NNTP.

Link: https://public-inbox.org/meta/20210426164454.5zd5kgugfhfwfkpo@nitro.local/T/
Diffstat (limited to 't')
-rw-r--r--t/lei-q-save.t30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/lei-q-save.t b/t/lei-q-save.t
index bea65133..694b33b2 100644
--- a/t/lei-q-save.t
+++ b/t/lei-q-save.t
@@ -3,6 +3,8 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
 use PublicInbox::Smsg;
+use List::Util qw(sum);
+
 my $doc1 = eml_load('t/plack-qp.eml');
 $doc1->header_set('Date', PublicInbox::Smsg::date({ds => time - (86400 * 5)}));
 my $doc2 = eml_load('t/utf8.eml');
@@ -165,5 +167,33 @@ test_lei(sub {
                         skip "symlinks not supported in $home?: $!", 1;
                 lei_ok('up', "$home/ln -s");
         };
+
+        my $v2 = "$home/v2"; # v2: as an output destination
+        my (@before, @after);
+        require PublicInbox::MboxReader;
+        lei_ok(qw(q z:0.. -o), "v2:$v2");
+        lei_ok(qw(q z:0.. -o), "mboxrd:$home/before", '--only', $v2, '-j1,1');
+        open my $fh, '<', "$home/before";
+        PublicInbox::MboxReader->mboxrd($fh, sub { push @before, $_[0] });
+        isnt(scalar(@before), 0, 'initial v2 written');
+        my $orig = sum(map { -f $_ ? -s _ : () } (
+                        glob("$v2/git/0.git/objects/*/*")));
+        lei_ok(qw(import t/data/0001.patch));
+        lei_ok 'up', $v2;
+        lei_ok(qw(q z:0.. -o), "mboxrd:$home/after", '--only', $v2, '-j1,1');
+        open $fh, '<', "$home/after";
+        PublicInbox::MboxReader->mboxrd($fh, sub { push @after, $_[0] });
+
+        my $last = shift @after;
+        $last->header_set('Status');
+        is_deeply($last, eml_load('t/data/0001.patch'), 'lei up worked on v2');
+        is_deeply(\@before, \@after, 'got same results');
+
+        my $v2s = "$home/v2s";
+        lei_ok(qw(q --shared z:0.. -o), "v2:$v2s");
+        my $shared = sum(map { -f $_ ? -s _ : () } (
+                        glob("$v2s/git/0.git/objects/*/*")));
+        ok($shared < $orig, 'fewer bytes stored with --shared') or
+                diag "shared=$shared orig=$orig";
 });
 done_testing;