unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 04/11] t/psgi_v2: minimal test for Atom feed and t.mbox.gz
Date: Tue, 27 Mar 2018 11:11:25 +0000	[thread overview]
Message-ID: <20180327111132.20681-5-e@80x24.org> (raw)
In-Reply-To: <20180327111132.20681-1-e@80x24.org>

Some test coverage is better than none, here.
---
 t/psgi_v2.t | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 6a2ea5b..7389798 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -43,6 +43,7 @@ $mime->body_set("hello world!\n");
 
 my @warn;
 local $SIG{__WARN__} = sub { push @warn, @_ };
+$mime->header_set(Date => 'Fri, 02 Oct 1993 00:01:00 +0000');
 ok($im->add($mime), 'added duplicate-but-different message');
 is(scalar(@warn), 1, 'got one warning');
 my @mids = $mime->header_obj->header_raw('Message-Id');
@@ -71,6 +72,12 @@ test_psgi(sub { $www->call(@_) }, sub {
 	like($raw, qr/^hello world!$/m, 'second message with new Message-Id');
 	@from_ = ($raw =~ m/^From /mg);
 	is(scalar(@from_), 1, 'only one From_ line');
+
+	# Atom feed should sort by Date: (if Received is missing)
+	$res = $cb->(GET('/v2test/new.atom'));
+	my @bodies = ($res->content =~ />(hello [^<]+)</mg);
+	is_deeply(\@bodies, [ "hello world!\n", "hello world\n" ],
+		'Atom ordering is chronological');
 });
 
 $mime->header_set('Message-Id', 'a-mid@b');
@@ -99,6 +106,21 @@ test_psgi(sub { $www->call(@_) }, sub {
 	like($raw, qr/^hello ghosts$/m, 'got third message');
 	@from_ = ($raw =~ m/^From /mg);
 	is(scalar(@from_), 3, 'three From_ lines');
+
+	SKIP: {
+		eval { require IO::Uncompress::Gunzip };
+		skip 'IO::Uncompress::Gunzip missing', 4 if $@;
+
+		$res = $cb->(GET('/v2test/a-mid@b/t.mbox.gz'));
+		my $out;
+		my $in = $res->content;
+		my $status = IO::Uncompress::Gunzip::gunzip(\$in => \$out);
+		like($out, qr/^hello world$/m, 'got first in t.mbox.gz');
+		like($out, qr/^hello world!$/m, 'got second in t.mbox.gz');
+		like($out, qr/^hello ghosts$/m, 'got third in t.mbox.gz');
+		@from_ = ($raw =~ m/^From /mg);
+		is(scalar(@from_), 3, 'three From_ lines in t.mbox.gz');
+	};
 });
 
 done_testing();
-- 
EW


  parent reply	other threads:[~2018-03-27 11:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-27 11:11 [PATCH 00/11] duplicate support in UI + tests Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 01/11] import: consolidate mid prepend logic, here Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 02/11] www: $MESSAGE_ID/raw endpoint supports "duplicates" Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 03/11] search: reopen DB if each_smsg_by_mid fails Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` Eric Wong (Contractor, The Linux Foundation) [this message]
2018-03-27 11:11 ` [PATCH 05/11] feed: fix new.html for v2 Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 06/11] view: permalink (per-message) view shows multiple messages Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 07/11] searchidx: warn about vivifying multiple ghosts Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 08/11] v2writable: warn on unseen deleted files Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 09/11] www: get rid of unnecessary 'inbox' name reference Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 10/11] searchview: remove unnecessary imports from MID module Eric Wong (Contractor, The Linux Foundation)
2018-03-27 11:11 ` [PATCH 11/11] view: depend on SearchMsg for Message-ID Eric Wong (Contractor, The Linux Foundation)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180327111132.20681-5-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).