user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/2] test for PublicInbox::Filter::RubyLang
Date: Thu, 22 Jun 2017 22:02:11 +0000	[thread overview]
Message-ID: <20170622220211.8956-2-e@80x24.org> (raw)
In-Reply-To: <20170622220211.8956-1-e@80x24.org>

This will make it easier to prevent breakage in the future.
---
 MANIFEST            |  1 +
 t/filter_rubylang.t | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 t/filter_rubylang.t

diff --git a/MANIFEST b/MANIFEST
index c7c4a92..43ac991 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -130,6 +130,7 @@ t/fail-bin/spamc
 t/feed.t
 t/filter_base.t
 t/filter_mirror.t
+t/filter_rubylang.t
 t/filter_subjecttag.t
 t/filter_vger.t
 t/git-http-backend.psgi
diff --git a/t/filter_rubylang.t b/t/filter_rubylang.t
new file mode 100644
index 0000000..bfccc35
--- /dev/null
+++ b/t/filter_rubylang.t
@@ -0,0 +1,58 @@
+# Copyright (C) 2017 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use strict;
+use warnings;
+use Test::More;
+use Email::MIME;
+use File::Temp qw/tempdir/;
+use_ok 'PublicInbox::Filter::RubyLang';
+
+my $f = PublicInbox::Filter::RubyLang->new;
+ok($f, 'created PublicInbox::Filter::RubyLang object');
+my $msg = <<'EOF';
+Subject: test
+
+keep this
+
+Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
+<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
+EOF
+my $mime = Email::MIME->new($msg);
+my $ret = $f->delivery($mime);
+is($ret, $mime, "delivery successful");
+is($mime->body, "keep this\n", 'normal message filtered OK');
+
+SKIP: {
+	eval 'require DBD::SQLite';
+	skip 'DBD::SQLite missing for altid mapping', 4 if $@;
+	use_ok 'PublicInbox::Inbox';
+	my $git_dir = tempdir('pi-filter_rubylang-XXXXXX',
+				TMPDIR => 1, CLEANUP => 1);
+	is(mkdir("$git_dir/public-inbox"), 1, "created public-inbox dir");
+	my $altid = [ "serial:ruby-core:file=msgmap.sqlite3" ];
+	my $ibx = PublicInbox::Inbox->new({ mainrepo => $git_dir,
+						altid => $altid });
+	$f = PublicInbox::Filter::RubyLang->new(-inbox => $ibx);
+	$msg = <<'EOF';
+X-Mail-Count: 12
+Message-ID: <a@b>
+
+EOF
+	$mime = Email::MIME->new($msg);
+	$ret = $f->delivery($mime);
+	is($ret, $mime, "delivery successful");
+	my $mm = PublicInbox::Msgmap->new($git_dir);
+	is($mm->num_for('a@b'), 12, 'MM entry created based on X-ML-Count');
+
+	$msg = <<'EOF';
+X-Mail-Cout: 12
+Message-ID: <b@b>
+
+EOF
+
+	$mime = Email::MIME->new($msg);
+	$ret = $f->delivery($mime);
+	is($ret, 100, "delivery rejected without X-Mail-Count");
+}
+
+done_testing();
-- 
EW


      reply	other threads:[~2017-06-22 22:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 23:33 [REJECT] add filter for RubyLang lists Eric Wong
2017-06-22  0:31 ` Eric Wong
2017-06-22  7:11 ` [PATCH v2] " Eric Wong
2017-06-22 22:02   ` [PATCH 1/2] filter/rubylang: reuse altid entry from inbox object Eric Wong
2017-06-22 22:02     ` Eric Wong [this message]

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: http://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=20170622220211.8956-2-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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).