Wrap a long line.
[ikiwiki] / t / podcast.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4
5 BEGIN {
6         eval q{use XML::Feed};
7         if ($@) {
8                 eval q{use Test::More skip_all => "XML::Feed not available"};
9         }
10         else {
11                 eval q{use Test::More tests => 36};
12         }
13 }
14
15 sub simple_podcast {
16         my $baseurl = 'http://example.com';
17         my @command = (qw(./ikiwiki.out -plugin inline -rss -atom));
18         push @command, qw(-underlaydir=underlays/basewiki);
19         push @command, qw(-set underlaydirbase=underlays -templatedir=templates);
20         push @command, "-url=$baseurl", qw(t/tinypodcast t/tmp/out);
21
22         ok(! system("mkdir t/tmp"));
23         ok(! system(@command));
24
25         my %media_types = (
26                 'piano.mp3'     => 'audio/mpeg',
27                 'scroll.3gp'    => 'video/3gpp',
28                 'walter.ogg'    => 'video/x-theora+ogg',
29         );
30
31         for my $format (qw(atom rss)) {
32                 my $feed = XML::Feed->parse("t/tmp/out/index.$format");
33
34                 is($feed->title, 'wiki', qq{$format feed title});
35                 is($feed->link, "$baseurl/", qq{$format feed link});
36                 is($feed->description, $feed->title, qq{$format feed description});
37                 if ('atom' eq $format) {
38                         is($feed->author, $feed->title, qq{$format feed author});
39                         is($feed->id, "$baseurl/", qq{$format feed id});
40                         is($feed->generator, "ikiwiki", qq{$format feed generator});
41                 }
42
43                 for my $entry ($feed->entries) {
44                         my $title = $entry->title;
45                         my $url = $entry->id;
46                         my $enclosure = $entry->enclosure;
47
48                         is($url, "$baseurl/$title", qq{$format $title id});
49                         is($entry->link, $url, qq{$format $title link});
50                         is($enclosure->url, $url, qq{$format $title enclosure url});
51                         is($enclosure->type, $media_types{$title}, qq{$format $title enclosure type});
52                         # is($enclosure->length, '12345', qq{$format $title enclosure length});
53                         # creation date
54                         # modification date
55                 }
56         }
57
58         ok(! system("rm -rf t/tmp t/tinypodcast/.ikiwiki"));
59 }
60
61 simple_podcast();