From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9D4DE1F601 for ; Fri, 19 Aug 2022 09:07:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1660900066; bh=rVoFQBW/SBNw0ZNQCKWR9r61d4RjtFtMYb5t6eJHsE0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=2Q6jhVkhruU78Zj/477n8UiwuoH8ivqaZ65r7eRyU/6qgBeh/WOLZZTDDUi0nEwh+ Nv5s+eug5dLhdzRgOkHfcIX8WkRuBWa1psL3glBVVyRhzYcWPU0RvcM1AW5b7OWmUX il9XR+KyFjsajGa2FFlPxFCZ9o2xg9Yme127ZXPY= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] tests: add some basic "lei reindex" tests Date: Fri, 19 Aug 2022 09:07:43 +0000 Message-Id: <20220819090745.4094018-3-e@80x24.org> In-Reply-To: <20220819090745.4094018-1-e@80x24.org> References: <20220819090745.4094018-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This is a bit hard-to-test, but at least we must ensure volatile-metadata is preserved. --- MANIFEST | 1 + t/lei-index.t | 12 +++++++++++- t/lei-reindex.t | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 t/lei-reindex.t diff --git a/MANIFEST b/MANIFEST index 27e4c4e0..43128382 100644 --- a/MANIFEST +++ b/MANIFEST @@ -477,6 +477,7 @@ t/lei-q-remote-import.t t/lei-q-save.t t/lei-q-thread.t t/lei-refresh-mail-sync.t +t/lei-reindex.t t/lei-sigpipe.t t/lei-tag.t t/lei-up.t diff --git a/t/lei-index.t b/t/lei-index.t index aab8f7e6..c31b1c3c 100644 --- a/t/lei-index.t +++ b/t/lei-index.t @@ -1,5 +1,5 @@ #!perl -w -# Copyright (C) 2021 all contributors +# Copyright (C) all contributors # License: AGPL-3.0+ use strict; use v5.10.1; use PublicInbox::TestCommon; use File::Spec; @@ -85,6 +85,10 @@ test_lei({ tmpdir => $tmpdir }, sub { lei_ok qw(q m:multipart-html-sucks@11); is_deeply(json_utf8->decode($lei_out)->[0]->{'kw'}, ['seen'], 'keyword set'); + lei_ok 'reindex'; + lei_ok qw(q m:multipart-html-sucks@11); + is_deeply(json_utf8->decode($lei_out)->[0]->{'kw'}, + ['seen'], 'keyword still set after reindex'); $srv->{nntpd} and lei_ok('index', "nntp://$srv->{nntp_host_port}/t.v2"); @@ -104,6 +108,12 @@ test_lei({ tmpdir => $tmpdir }, sub { my $t = xqx(['git', "--git-dir=$store_path/ALL.git", qw(cat-file -t), $res_b->{blob}]); is($t, "blob\n", 'got blob'); + + lei_ok('reindex'); + lei_ok qw(q m:multipart-html-sucks@11); + $res_a = json_utf8->decode($lei_out)->[0]; + is_deeply($res_a->{'kw'}, ['seen'], + 'keywords still set after reindex'); }); done_testing; diff --git a/t/lei-reindex.t b/t/lei-reindex.t new file mode 100644 index 00000000..73346ee8 --- /dev/null +++ b/t/lei-reindex.t @@ -0,0 +1,12 @@ +#!perl -w +# Copyright (C) all contributors +# License: AGPL-3.0+ +use v5.12; use PublicInbox::TestCommon; +require_mods(qw(lei)); +my ($tmpdir, $for_destroy) = tmpdir; +test_lei(sub { + ok(!lei('reindex'), 'reindex fails w/o store'); + like $lei_err, qr/nothing indexed/, "`nothing indexed' noted"; +}); + +done_testing;