root/trunk/plagger/t/plugins/CustomFeed-Debug/test.t

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

CustomFeed?::Debug: allow 'entries' key. auto_set_type on enclosures. Update tests

Line 
1 use strict;
2 use t::TestPlagger;
3
4 plan 'no_plan';
5
6 run_eval_expected;
7
8 __END__
9
10 === Test Debug
11 --- input config
12 plugins:
13   - module: CustomFeed::Debug
14     config:
15       title: 'My Feed'
16       link: 'http://localhost/'
17       entry:
18         - title: 'First Entry'
19           link: 'http://localhost/1'
20           body: 'Hello World! :)'
21         - title: 'Second Entry'
22           link: 'http://localhost/2'
23           body: 'Good Bye! :P'
24
25 --- expected
26 is $context->update->feeds->[0]->link, 'http://localhost/';
27 is $context->update->feeds->[0]->title, 'My Feed';
28 ok $context->update->feeds->[0]->count;
29 ok $context->update->feeds->[0]->entries->[0]->title;
30 ok $context->update->feeds->[0]->entries->[0]->link;
31 ok $context->update->feeds->[0]->entries->[0]->body;
32 ok $context->update->feeds->[0]->entries->[1]->title;
33 ok $context->update->feeds->[0]->entries->[1]->link;
34 ok $context->update->feeds->[0]->entries->[1]->body;
35
36 === Enclosures
37 --- input config
38 plugins:
39   - module: CustomFeed::Debug
40     config:
41       title: 'My Feed'
42       link: 'http://localhost/'
43       entry:
44         - title: 'First Entry'
45           link: 'http://localhost/1'
46           body: 'Hello World! :)'
47           enclosure:
48             url: http://example.com/foo.mp3
49             length: 123
50             type: audio/mp3
51
52         - title: 'First Entry'
53           link: 'http://localhost/1'
54           body: 'Hello World! :)'
55           enclosure:
56             - url: http://example.com/foo.mp3
57               length: 123
58             - url: http://example.com/foo.m4a
59               length: 456
60 --- expected
61 is $context->update->feeds->[0]->link, 'http://localhost/';
62 is $context->update->feeds->[0]->title, 'My Feed';
63 {
64     my @e = $context->update->feeds->[0]->entries->[0]->enclosures;
65     is @e, 1;
66     isa_ok $e[0]->url, 'URI';
67     is $e[0]->url, 'http://example.com/foo.mp3';
68     is $e[0]->type, 'audio/mp3';
69     is $e[0]->length, 123;
70 }
71 {
72     my @e = $context->update->feeds->[0]->entries->[1]->enclosures;
73     is @e, 2;
74     isa_ok $e[0]->url, 'URI';
75     is $e[0]->url, 'http://example.com/foo.mp3';
76     is $e[0]->type, 'audio/mpeg';
77     is $e[0]->length, 123;
78     is $e[1]->url, 'http://example.com/foo.m4a';
79     is $e[1]->type, 'audio/aac';
80     is $e[1]->length, 456;
81 }
82
83
Note: See TracBrowser for help on using the browser.