/[Grep]/t/00-action-Search.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /t/00-action-Search.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 148 by dpavlin, Sat Jun 9 09:15:14 2007 UTC revision 152 by dpavlin, Sat Jun 9 10:27:19 2007 UTC
# Line 8  A (very) basic test harness for the Sear Line 8  A (very) basic test harness for the Sear
8    
9  =cut  =cut
10    
11  use Jifty::Test tests => 15;  use Jifty::Test tests => 29;
12    
13  # Make sure we can load the action  # Make sure we can load the action
14  use_ok('Grep::Action::Search');  use_ok('Grep::Action::Search');
# Line 21  use_ok('Grep::Model::Feed'); Line 21  use_ok('Grep::Model::Feed');
21  my $system_user = Grep::CurrentUser->superuser;  my $system_user = Grep::CurrentUser->superuser;
22  ok($system_user, "Found a system user");  ok($system_user, "Found a system user");
23    
24    {
25            use Log::Log4perl::Level;
26            Jifty->web->log->level( $DEBUG );
27    }
28    
29  # create test feed  # create test feed
30  my $feed = Grep::Model::Feed->new(current_user => $system_user);  my $feed = Grep::Model::Feed->new(current_user => $system_user);
31  my ($id) = $feed->create(  my ($id) = $feed->create(
# Line 43  ok($id, "Item create returned success"); Line 48  ok($id, "Item create returned success");
48  ok($o->id, "New Item has valid id set");  ok($o->id, "New Item has valid id set");
49  is($o->id, $id, "Create returned the right id");  is($o->id, $id, "Create returned the right id");
50    
51    use_ok('Grep::Search');
52    ok(my $index = Grep::Search->new, 'Grep::Search->new');
53    isa_ok( $index, 'Grep::Search' );
54    
55    ok($index->add( $o, $system_user->id ), 'add ' . $o->id );
56    
57    ok($index->finish, 'finish');
58    
59  # Searches in general  # Searches in general
60  my $collection =  Grep::Model::ItemCollection->new(current_user => $system_user);  my $collection =  Grep::Model::ItemCollection->new(current_user => $system_user);
61  $collection->unlimit;  $collection->unlimit;
# Line 57  my $search = Jifty::Test->web->new_actio Line 70  my $search = Jifty::Test->web->new_actio
70    
71  isa_ok($search, 'Grep::Action::Search');  isa_ok($search, 'Grep::Action::Search');
72    
 {  
         use Log::Log4perl::Level;  
         Jifty->web->log->level( $DEBUG );  
 }  
   
73  my %args = %{$search->arguments};  my %args = %{$search->arguments};
74    
75  ok($args{q}, "Can search on q");  ok($args{q}, "Can search on q");
# Line 74  my $result = $search->result->content('s Line 82  my $result = $search->result->content('s
82    
83  isa_ok($result, 'Jifty::Collection');  isa_ok($result, 'Jifty::Collection');
84  is($result->count, 1);  is($result->count, 1);
 is($result->first->name, 'test1');  
85    
86    isa_ok( $result->first, 'Grep::Model::Item' );
87    
88    eval {
89    is($result->first->in_feed->id, $feed->id);
90    is($result->first->title, 'example title');
91    is($result->first->link, 'http://www.example.com/item1');
92    is($result->first->content, 'some content');
93    };
94    
95    ok($index = Grep::Search->new, 'Grep::Search->new');
96    isa_ok( $index, 'Grep::Search' );
97    ok($index->invindexer->delete_by_term( 'id', $o->id ), 'invindexer->delete_by_term( id, ' . $o->id . ')' );
98    
99    ok($index->finish, 'finish');

Legend:
Removed from v.148  
changed lines
  Added in v.152

  ViewVC Help
Powered by ViewVC 1.1.26