From 9d197b8e58243e39b995ee7aa99e398f356b926c Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Sun, 28 Apr 2019 15:00:43 +0100 Subject: [PATCH 1/2] indexer tests: use the new meta_munger to create bogus metadata --- corpus/Provides-NoFile-0.50.tar.gz | Bin 1092 -> 0 bytes t/mldistwatch-big.t | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) delete mode 100644 corpus/Provides-NoFile-0.50.tar.gz diff --git a/corpus/Provides-NoFile-0.50.tar.gz b/corpus/Provides-NoFile-0.50.tar.gz deleted file mode 100644 index e38eb57212786e42c7ef1bcac0b6a5905dc34cdd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1092 zcmV-K1iSkmiwFP!jm2C51MOM=kJ>gAzn}eAc-bUc=?G59mnpY)qcExXK;`id`_wgs8!{h5<#FA<|ei?+UN_3ml zPKpH~#I`DdeN((Fz{KF zFb~fe577*6tR{2j%Meo@dUz_t+^f}Q@hF82twPe1IORSY$9%%{hzYgB)m_zVL$~y) zn1yir$|(c|ofQOugO{BOLG#uB(qA^_dCNiBzMnGA;tkAXB{xcNc+E`kuq zNhV(Y@iT<}PIv-z^y@{h-)^*;_}O!;?d%)v6b#g$#I`}kc*^3BX18~7*@1H=@qSI}5o4*Y@EopL#p=WW5o}Qt@&sSnU9@c;IrLPzt2kPH2 zEpwy)th%g!qh2rT{}{NHIz!78poTs8XQu*HjY78)g3{tIrA?q~zZ}%0+26~X@2WsK z30V$oi$Uf6k#cYq+)5MPiB8JHfxR8YS}RJs+sqC`qw>7cjR~XNpX%yCKrhzhG^5!6 zc{{M4oZ~c`U=^I2#8mzkOMg;8s@^=dgaA1x#dnDcW|4I*4etbak4j+-Ym%1Lo!w@gF9*MJ%(S!}497L+Z)ZlWsex~iUSQ9+f9?+`F z>{ag)7PiybO0wx%gbWBQ=Az{IuZjot|9VG#xsONaf5#*i@V`s!^85c$a5(>KM)}7+ z4(WelyLa<%65FxL^Zyu_0};~+yZ3?O48 sub { subtest "sometimes, provides fields are empty" => sub { my $pause = PAUSE::TestPAUSE->init_new; - # Key points: - # 1. dist version 0.50 - # 2. meta provides has... - # a. package Provides::NoFile in a named file with version 1.5 - # b. package Provides::NoFile::Nowhere with an undef file entry - $pause->upload_author_file(MYSTERIO => 'corpus/Provides-NoFile-0.50.tar.gz'); + $pause->upload_author_fake( + MYSTERIO => 'Provides-NoFile-0.50.tar.gz', + { + meta_munger => sub { + $_[0]{provides} = { + "Provides::NoFile" => { file => "lib/Provides/NoFile.pm", version => "1.5" }, + "Provides::NoFile::Nowhere" => { file => undef }, + }; + + return $_[0]; + }, + } + ); my $result = $pause->test_reindex; From f4ef74f5757f51f8460e0274d09fcf00a3add1cf Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Tue, 30 Apr 2019 07:33:22 -0400 Subject: [PATCH 2/2] TestPAUSE: add a means to force rewrite_indexes --- t/lib/PAUSE/TestPAUSE.pm | 46 +++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/t/lib/PAUSE/TestPAUSE.pm b/t/lib/PAUSE/TestPAUSE.pm index e423f6bff..031894b42 100644 --- a/t/lib/PAUSE/TestPAUSE.pm +++ b/t/lib/PAUSE/TestPAUSE.pm @@ -313,9 +313,8 @@ sub with_our_config { $code->($self); } -sub test_reindex { - my ($self, $arg) = @_; - $arg //= {}; +sub _take_pause_action { + my ($self, $action) = @_; $self->with_our_config(sub { my $self = shift; @@ -349,18 +348,7 @@ sub test_reindex { die "stray mail in test mail trap before reindex" if @stray_mail; - if ($arg->{pick}) { - my $dbh = PAUSE::dbh(); - $dbh->do("DELETE FROM distmtimes WHERE dist = ?", undef, $_) - for @{ $arg->{pick} }; - } - - PAUSE::mldistwatch->new({ - sleep => 0, - ($arg->{pick} ? (pick => $arg->{pick}) : ()), - })->reindex; - - $arg->{after}->($self->tmpdir) if $arg->{after}; + $action->(); my @deliveries = Email::Sender::Simple->default_transport->deliveries; @@ -376,6 +364,34 @@ sub test_reindex { }); } +sub rewrite_indexes { + my ($self) = @_; + my $action = sub { + PAUSE::mldistwatch->new({ sleep => 0 })->rewrite_indexes; + }; + + return $self->_take_pause_action($action); +} + +sub test_reindex { + my ($self, $arg) = @_; + $arg //= {}; + my $action = sub { + if ($arg->{pick}) { + my $dbh = PAUSE::dbh(); + $dbh->do("DELETE FROM distmtimes WHERE dist = ?", undef, $_) + for @{ $arg->{pick} }; + } + + PAUSE::mldistwatch->new({ + sleep => 0, + ($arg->{pick} ? (pick => $arg->{pick}) : ()), + })->reindex; + }; + + return $self->_take_pause_action($action); +} + has _file_index => ( is => 'ro', default => sub { {} },