* [PATCH 2/2] test for PublicInbox::Filter::RubyLang
@ 2017-06-22 22:02 7% ` Eric Wong
0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2017-06-22 22:02 UTC (permalink / raw)
To: meta
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
^ permalink raw reply related [relevance 7%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-06-22 7:11 [PATCH v2] add filter for RubyLang lists 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 7% ` [PATCH 2/2] test for PublicInbox::Filter::RubyLang Eric Wong
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).