root/trunk/plagger/t/plugins/Search-KinoSearch/search.t

Revision 1391 (checked in by miyagawa, 14 years ago)

merge from hackathon-mt

Line 
1 use strict;
2 use FindBin;
3 use File::Spec;
4 use File::Path;
5 use t::TestPlagger;
6
7 test_plugin_deps;
8
9 our $dir = File::Spec->catfile($FindBin::Bin, 'invindex');
10
11 plan tests => 8;
12 run_eval_expected;
13
14 END {
15     rmtree $dir if $dir && -e $dir;
16 }
17
18 __END__
19
20 === Search
21 --- input config
22 plugins:
23   - module: Subscription::Config
24     config:
25       feed:
26         - file://$t::TestPlagger::BaseDirURI/t/samples/vox.xml
27   - module: Search::KinoSearch
28     config:
29       invindex: $main::dir
30 --- expected
31 ok -e $main::dir, 'invindex exists';
32 Plagger->set_context($context);
33
34 my $feed;
35 $context->run_hook('searcher.search', { query => "murakami" }, 0, sub { $feed = $_[0] });
36 ok $feed, 'I got feed';
37 is $feed->count, 1, 'murakami matches 1';
38
39 $context->run_hook('searcher.search', { query => "foobar" }, 0, sub { $feed = $_[0] });
40 ok $feed, 'I still got feed';
41 is $feed->count, 0, 'No match';
42
43 === Second run ... make sure it's not clobbered
44 --- input config
45 plugins:
46   - module: Subscription::Config
47     config:
48       feed:
49         - file://$t::TestPlagger::BaseDirURI/t/samples/rss-full.xml
50   - module: Search::KinoSearch
51     config:
52       invindex: $main::dir
53 --- expected
54 ok -e $main::dir, 'invindex exists';
55 Plagger->set_context($context);
56
57 my $feed;
58 $context->run_hook('searcher.search', { query => "murakami" }, 0, sub { $feed = $_[0] });
59 ok $feed, 'I still got feed';
60 is $feed->count, 1, 'murakami matches 1';
61
Note: See TracBrowser for help on using the browser.