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

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

fixed file URLs for KinoSearch?

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
33 # xxx this is clumsy
34 no warnings 'redefine';
35 *Plagger::context = sub { $context };
36
37 my $feed;
38 $context->run_hook('searcher.search', { query => "murakami" }, 0, sub { $feed = $_[0] });
39 ok $feed, 'I got feed';
40 is $feed->count, 1, 'murakami matches 1';
41
42 $context->run_hook('searcher.search', { query => "foobar" }, 0, sub { $feed = $_[0] });
43 ok $feed, 'I still got feed';
44 is $feed->count, 0, 'No match';
45
46 === Second run ... make sure it's not clobbered
47 --- input config
48 plugins:
49   - module: Subscription::Config
50     config:
51       feed:
52         - file://$t::TestPlagger::BaseDirURI/t/samples/rss-full.xml
53   - module: Search::KinoSearch
54     config:
55       invindex: $main::dir
56 --- expected
57 ok -e $main::dir, 'invindex exists';
58
59 # xxx this is clumsy
60 no warnings 'redefine';
61 *Plagger::context = sub { $context };
62
63 my $feed;
64 $context->run_hook('searcher.search', { query => "murakami" }, 0, sub { $feed = $_[0] });
65 ok $feed, 'I still got feed';
66 is $feed->count, 1, 'murakami matches 1';
67
Note: See TracBrowser for help on using the browser.