diff options
Diffstat (limited to 't')
-rw-r--r-- | t/lei-mirror.t | 8 | ||||
-rw-r--r-- | t/v2mirror.t | 25 |
2 files changed, 33 insertions, 0 deletions
diff --git a/t/lei-mirror.t b/t/lei-mirror.t index 7dd03b26..de5246b6 100644 --- a/t/lei-mirror.t +++ b/t/lei-mirror.t @@ -65,6 +65,14 @@ test_lei({ tmpdir => $tmpdir }, sub { lei_ok('ls-external'); unlike($lei_out, qr!\Q$d\E!s, 'not added to ls-external'); + $d = "$home/bad-epoch"; + ok(!lei(qw(add-external -q --epoch=0.. --mirror), "$http/t1/", $d), + 'v1 fails on --epoch'); + ok(!-d $d, 'destination not created on unacceptable --epoch'); + ok(!lei(qw(add-external -q --epoch=1 --mirror), "$http/t2/", $d), + 'v2 fails on bad epoch range'); + ok(!-d $d, 'destination not created on bad epoch'); + my %phail = ( HTTPS => 'https://public-inbox.org/' . 'phail', ONION => diff --git a/t/v2mirror.t b/t/v2mirror.t index 665a4d59..20a8daaa 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -263,6 +263,31 @@ if ('test read-only epoch dirs') { 'fetch restored objects once GIT_DIR became writable'); } +{ + my $dst = "$tmpdir/partial"; + run_script([qw(-clone -q --epoch=~0), "http://$host:$port/v2/", $dst]); + is($?, 0, 'no error from partial clone'); + my @g = glob("$dst/git/*.git"); + my @w = grep { -w $_ } @g; + my @r = grep { ! -w $_ } @g; + is(scalar(@w), 1, 'one writable directory'); + my ($w) = ($w[0] =~ m!/([0-9]+)\.git\z!); + is((grep { + m!/([0-9]+)\.git\z! or xbail "no digit in $_"; + $w > ($1 + 0) + } @r), scalar(@r), 'writable epoch # exceeds read-only ones'); + run_script([qw(-fetch -q)], undef, { -C => $dst }); + is($?, 0, 'no error from partial fetch'); + remove_tree($dst); + + run_script([qw(-clone -q --epoch=~1..), + "http://$host:$port/v2/", $dst]); + my @g2 = glob("$dst/git/*.git") ; + is_deeply(\@g2, \@g, 'cloned again'); + is(scalar(grep { -w $_ } @g2), scalar(@w) + 1, + 'got one more cloned epoch'); +} + ok($td->kill, 'killed httpd'); $td->join; |