]> Sergey Matveev's repositories - public-inbox.git/commitdiff
feed: add tests for <id> element setting
authorEric Wong <e@80x24.org>
Wed, 23 Apr 2014 01:05:56 +0000 (01:05 +0000)
committerEric Wong <e@80x24.org>
Wed, 23 Apr 2014 01:23:47 +0000 (01:23 +0000)
We need to ensure this works

This follows commit bd8fd095067b79a0d2a40bbca2b27b923d02b3f8
("feed: fix address when multiple addresses exist")

t/feed.t

index 379f8d398fbcead3e31b899af73a3e303bc00412..3e1c6d7be29f57ecf67973fbd855f147106797ab 100644 (file)
--- a/t/feed.t
+++ b/t/feed.t
@@ -5,6 +5,7 @@ use warnings;
 use Test::More;
 use Email::Simple;
 use PublicInbox::Feed;
+use PublicInbox::Config;
 use File::Temp qw/tempdir/;
 my $have_xml_feed = eval { require XML::Feed; 1 };
 
@@ -46,7 +47,10 @@ EOF
                print $pipe $simple->as_string or die "print failed: $!\n";
                close $pipe or die "close pipe failed: $!\n";
        }
+}
 
+# spam check
+{
        # check initial feed
        {
                my $feed = PublicInbox::Feed->generate({
@@ -58,6 +62,8 @@ EOF
                        my $p = XML::Feed->parse(\$feed);
                        is($p->format, "Atom", "parsed atom feed");
                        is(scalar $p->entries, 3, "parsed three entries");
+                       is($p->id, 'public-inbox@example.com',
+                               "id is set to default");
                }
                unlike($feed, qr/drop me/, "long quoted text dropped");
                like($feed, qr/inline me here/, "short quoted text kept");
@@ -127,4 +133,25 @@ EOF
        }
 }
 
+# check pi_config
+{
+       foreach my $addr (('a@example.com'), ['a@example.com','b@localhost']) {
+               my $feed = PublicInbox::Feed->generate({
+                       git_dir => $git_dir,
+                       max => 3,
+                       listname => 'asdf',
+                       pi_config => bless({
+                               'publicinbox.asdf.address' => $addr,
+                       }, 'PublicInbox::Config'),
+               });
+               SKIP: {
+                       skip 'XML::Feed missing', 3 unless $have_xml_feed;
+                       my $p = XML::Feed->parse(\$feed);
+                       is($p->id, 'a@example.com', "ID is set correctly");
+                       is($p->format, "Atom", "parsed atom feed");
+                       is(scalar $p->entries, 3, "parsed three entries");
+               }
+       }
+}
+
 done_testing();