Skip to content

Commit cce27c5

Browse files
committed
fix release indexing and CVE test
1 parent 835fec3 commit cce27c5

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

lib/MetaCPAN/Release.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ sub document_module ( $self, %args ) {
265265
version => $version,
266266
version_numified => numify_version($version),
267267
};
268+
269+
return $document;
268270
}
269271

270272
sub document_release ( $self, %args ) {
@@ -293,8 +295,10 @@ sub document_release ( $self, %args ) {
293295
stat => $stat,
294296
status => $self->{status},
295297

296-
# Call in scalar context to make sure we only get one value (building a hash).
297-
( map { ( $_ => scalar $meta->$_ ) } qw< version resources > ),
298+
# Call in scalar context to make sure we only get one value (building a hash).
299+
resources => scalar $meta->resources,
300+
version => scalar $meta->version,
301+
version_numified => numify_version(scalar $meta->version),
298302
};
299303

300304
return $document;

t/00_setup.t

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,26 @@ subtest 'Contributor Indexing' => sub {
175175
"Found ($contributor_count) contributors for HTML-Parser-3.83" );
176176
};
177177

178+
subtest 'CVE Indexing' => sub {
179+
my $cve_script = $d_bin->child('cve.pl');
180+
my $json = $d_test->child('cve_dev.json');
181+
182+
# run the CVE indexing script
183+
`perl $cve_script -json $json`;
184+
185+
my $es_cve = MetaCPAN::ES->new( index => 'cve' );
186+
my $cve_count = $es_cve->count(
187+
body => {
188+
query => { match => { distribution => 'HTML-Parser' } },
189+
}
190+
)->{count};
191+
ok( $cve_count > 0,
192+
"Found ($cve_count) test CVEs" );
193+
};
194+
178195
# TODO:
179-
# cve
180196
# favorite
181197

182-
# check test data directory
183-
# - check all distros for test are there
184-
# - check all other data sources are there to test all indices
185-
# set ES object with (elasticsearch_test)
186-
# - check object's config
187-
188198
# $server->set_latest;
189199
# $server->set_first;
190200
# $server->prepare_user_test_data;

test_data/cve_dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"cves": null,
1010
"severity": null,
1111
"affected_versions": [
12-
">=1.25,<2.3.9"
12+
">=1.25,<4"
1313
],
1414
"cpansa_id": "CPANSA-HTML-Parser-2025-0666",
1515
"reported": "2025-10-10"

0 commit comments

Comments
 (0)