diff options
author | Eric Wong <e@80x24.org> | 2021-09-12 07:47:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-09-12 07:48:57 +0000 |
commit | 715f2505c0aab512ed99631697c0c3edf0062c26 (patch) | |
tree | 470c78cdfb93377d3d46b64ed261e55f9361bd5f /t/lei-mirror.t | |
parent | b45a1dffa647f6427d0c900fcc55753db7a1994c (diff) | |
download | public-inbox-715f2505c0aab512ed99631697c0c3edf0062c26.tar.gz |
Instead of generic "Unnamed repository" or "missing" messages, show "mirror of $URL" since it seems like a better default when creating a mirror.
Diffstat (limited to 't/lei-mirror.t')
-rw-r--r-- | t/lei-mirror.t | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/lei-mirror.t b/t/lei-mirror.t index 75e25b3f..35b77cf7 100644 --- a/t/lei-mirror.t +++ b/t/lei-mirror.t @@ -2,6 +2,7 @@ # Copyright (C) 2020-2021 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 PublicInbox::Inbox; require_mods(qw(-httpd lei)); my $sock = tcp_server(); my ($tmpdir, $for_destroy) = tmpdir(); @@ -15,6 +16,8 @@ test_lei({ tmpdir => $tmpdir }, sub { my $t1 = "$home/t1-mirror"; lei_ok('add-external', $t1, '--mirror', "$http/t1/", \'--mirror v1'); ok(-f "$t1/public-inbox/msgmap.sqlite3", 't1-mirror indexed'); + is(PublicInbox::Inbox::try_cat("$t1/description"), + "mirror of $http/t1/\n", 'description set'); lei_ok('ls-external'); like($lei_out, qr!\Q$t1\E!, 't1 added to ls-externals'); @@ -22,6 +25,9 @@ test_lei({ tmpdir => $tmpdir }, sub { my $t2 = "$home/t2-mirror"; lei_ok('add-external', $t2, '--mirror', "$http/t2/", \'--mirror v2'); ok(-f "$t2/msgmap.sqlite3", 't2-mirror indexed'); + ok(-f "$t2/description", 't2 description'); + is(PublicInbox::Inbox::try_cat("$t2/description"), + "mirror of $http/t2/\n", 'description set'); lei_ok('ls-external'); like($lei_out, qr!\Q$t2\E!, 't2 added to ls-externals'); @@ -109,4 +115,21 @@ SKIP: { ok($td->kill, 'killed -httpd'); $td->join; +{ + require_ok 'PublicInbox::LeiMirror'; + my $mrr = { src => 'https://example.com/src/', dst => $tmpdir }; + my $exp = "mirror of https://example.com/src/\n"; + my $f = "$tmpdir/description"; + PublicInbox::LeiMirror::set_description($mrr); + is(PublicInbox::Inbox::try_cat($f), $exp, 'description set on ENOENT'); + + my $fh; + (open($fh, '>', $f) and close($fh)) or xbail $!; + PublicInbox::LeiMirror::set_description($mrr); + is(PublicInbox::Inbox::try_cat($f), $exp, 'description set on empty'); + (open($fh, '>', $f) and print $fh "x\n" and close($fh)) or xbail $!; + is(PublicInbox::Inbox::try_cat($f), "x\n", + 'description preserved if non-default'); +} + done_testing; |