App-CSE
view release on metacpan or search on metacpan
t/05-more-search.t view on Meta::CPAN
#! perl -T
use Test::More;
use Log::Log4perl qw/:easy/;
# Log::Log4perl->easy_init($TRACE);
binmode STDOUT , ':utf8';
binmode STDERR , ':utf8';
use App::CSE;
use Carp::Always;
use File::Temp;
use Path::Class::Dir;
use File::BaseDir qw//;
unless( File::BaseDir::data_files('mime/globs') ){
plan skip_all => 'No mime-info database on the machine. The shared-mime-info package is available from http://freedesktop.org/';
}
my $idx_dir = File::Temp->newdir( CLEANUP => 1 );
my $content_dir = Path::Class::Dir->new('t/toindex');
# We are trying to cover as many languages from http://langpop.corger.nl/
# as possible.
{
## Searching for some javascript.
local @ARGV = ( '--idx='.$idx_dir, 'javascriptIsGreat', '--dir='.$content_dir.'');
my $cse = App::CSE->new();
is( $cse->command()->execute(), 0 , "Ok execute has terminated just fine");
ok( $cse->command()->hits() , "Ok got hits");
is( $cse->command()->hits()->total_hits() , 1 , "Ok got one hit");
}
{
## Searching for 'isgreat' in javascript
local @ARGV = ( '--idx='.$idx_dir, 'isgreat', '--dir='.$content_dir.'');
my $cse = App::CSE->new();
is( $cse->command()->execute(), 0 , "Ok execute has terminated just fine");
ok( $cse->command()->hits() , "Ok got hits");
is( $cse->command()->hits()->total_hits() , 1 , "Ok got one hit");
}
{
## Searching for some ruby
local @ARGV = ( '--idx='.$idx_dir, 'ruby');
my $cse = App::CSE->new();
is( $cse->command()->execute(), 0 , "Ok execute has terminated just fine");
ok( $cse->command()->hits() , "Ok got hits");
is( $cse->command()->hits()->total_hits() , 3 , "Ok got two hits (one is a directory)");
}
{
## Searching for some text file
local @ARGV = ( '--idx='.$idx_dir, 'search_for_text');
my $cse = App::CSE->new();
is( $cse->command()->execute(), 0 , "Ok execute has terminated just fine");
ok( $cse->command()->hits() , "Ok got hits");
is( $cse->command()->hits()->total_hits() , 1 , "Ok got one hit");
}
{
( run in 2.523 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )