@@ -2,94 +2,102 @@ use strict;
22use warnings;
33use lib ' t/lib' ;
44
5- use MetaCPAN::Server::Test qw( model query ) ;
5+ use MetaCPAN::Server::Test qw( query es_result ) ;
66use MetaCPAN::Util qw( true false ) ;
77use Test::More;
88
9- my $model = model();
10- my @moose
11- = $model -> doc(' release' )
12- -> query( { term => { distribution => ' Moose' } } )-> all;
9+ my @moose = es_result( ' release' , { term => { distribution => ' Moose' } } );
1310
1411my $first = 0;
15- map { $first ++ } grep { $_ -> first } @moose ;
12+ map { $first ++ } grep { $_ -> { first } } @moose ;
1613
1714is( $first , 1, ' only one moose is first' );
1815
19- is( $moose [0]-> main_module, ' Moose' , ' main_module ok' );
16+ is( $moose [0]-> { main_module } , ' Moose' , ' main_module ok' );
2017
21- is( $moose [1]-> main_module, ' Moose' , ' main_module ok' );
18+ is( $moose [1]-> { main_module } , ' Moose' , ' main_module ok' );
2219
23- ok(
24- my $faq
25- = $model -> doc(' file' )
26- -> query( { match_phrase => { documentation => ' Moose::FAQ' } } )
27- -> first,
28- ' get Moose::FAQ'
29- );
20+ my $faq = es_result( ' file' ,
21+ { match_phrase => { documentation => ' Moose::FAQ' } } );
22+
23+ ok( $faq , ' get Moose::FAQ' );
3024
31- is( $faq -> status, ' latest' , ' is latest' );
25+ is( $faq -> { status } , ' latest' , ' is latest' );
3226
33- ok( $faq -> indexed, ' is indexed' );
27+ ok( $faq -> { indexed } , ' is indexed' );
3428
35- ok( !$faq -> binary, ' is not binary' );
29+ ok( !$faq -> { binary } , ' is not binary' );
3630
37- ok(
38- my $binary
39- = $model -> doc(' file' )-> query( { term => { name => ' t' } } )-> first,
40- ' get a t/ directory'
31+ my $binary = es_result(
32+ ' file' ,
33+ {
34+ bool => {
35+ must => [
36+ { term => { release => ' Moose-0.01' } },
37+ { term => { name => ' t' } },
38+ ],
39+ },
40+ }
4141);
4242
43- ok( $binary -> binary , ' is binary ' );
43+ ok( $binary , ' get a t/ directory ' );
4444
45- ok(
46- my $ppport
47- = $model -> doc(' file' )
48- -> query( { match_phrase => { documentation => ' ppport.h' } } )-> first,
49- ' get ppport.h'
50- );
45+ ok( $binary -> {binary }, ' is binary' );
46+
47+ my $ppport = es_result( ' file' ,
48+ { match_phrase => { documentation => ' ppport.h' } } );
49+ ok( $ppport , ' get ppport.h' );
5150
52- is( $ppport -> name, ' ppphdoc' , ' name doesn\' t contain a dot' );
51+ is( $ppport -> { name } , ' ppphdoc' , ' name doesn\' t contain a dot' );
5352
5453my $signature ;
55- $signature = $model -> doc(' file' )-> query( {
56- bool => {
57- must => [
58- { term => { mime => ' text/x-script.perl' } },
59- { term => { name => ' SIGNATURE' } },
60- ],
61- },
62- } )-> first;
54+ ($signature ) = es_result(
55+ ' file' ,
56+ {
57+ bool => {
58+ must => [
59+ { term => { mime => ' text/x-script.perl' } },
60+ { term => { name => ' SIGNATURE' } },
61+ ],
62+ },
63+ }
64+ );
6365ok( !$signature , ' SIGNATURE is not perl code' );
6466
65- $signature = $model -> doc(' file' )-> query( {
66- bool => {
67- must => [
68- { term => { documentation => ' SIGNATURE' } },
69- { term => { mime => ' text/x-script.perl' } },
70- { term => { name => ' SIGNATURE' } },
71- ],
72- },
73- } )-> first;
67+ ($signature ) = es_result(
68+ ' file' ,
69+ {
70+ bool => {
71+ must => [
72+ { term => { documentation => ' SIGNATURE' } },
73+ { term => { mime => ' text/x-script.perl' } },
74+ { term => { name => ' SIGNATURE' } },
75+ ],
76+ },
77+ }
78+ );
7479ok( !$signature , ' SIGNATURE is not documentation' );
7580
76- $signature = $model -> doc(' file' )-> query( {
77- bool => {
78- must => [
79- { term => { name => ' SIGNATURE' } },
80- { exists => { field => ' documentation' } },
81- { term => { indexed => true } },
82- ],
83- },
84- } )-> first;
81+ ($signature ) = es_result(
82+ ' file' ,
83+ {
84+ bool => {
85+ must => [
86+ { term => { name => ' SIGNATURE' } },
87+ { exists => { field => ' documentation' } },
88+ { term => { indexed => true } },
89+ ],
90+ },
91+ }
92+ );
8593ok( !$signature , ' SIGNATURE is not pod' );
8694
8795{
8896 my $files = query()-> file;
8997 my $module = $files -> history( module => ' Moose' );
9098 my $file = $files -> history( file => ' Moose' , ' lib/Moose.pm' );
9199
92- is_deeply( $module -> {hits }, $file -> {hits },
100+ is_deeply( $module -> {files }, $file -> {files },
93101 ' history of Moose and lib/Moose.pm match' );
94102 is( $module -> {total }, 2, ' two hits' );
95103
0 commit comments