add a test for mhbuild rfc2047-support
authorPhilipp Takacs <philipp@bureaucracy.de>
Fri, 25 Sep 2015 10:50:56 +0000 (12:50 +0200)
committerPhilipp Takacs <philipp@bureaucracy.de>
Sat, 10 Oct 2015 12:35:58 +0000 (14:35 +0200)
This is only the first test, more come later.

test/tests/mhbuild/test-header-encode [new file with mode: 0644]

diff --git a/test/tests/mhbuild/test-header-encode b/test/tests/mhbuild/test-header-encode
new file mode 100644 (file)
index 0000000..9049f6f
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+######################################################
+#
+# Test encoding headers according to RFC 2047
+#
+######################################################
+
+# TODO: Move to a common file tests can source; need more framework...
+failed=0
+check() {
+    diff -u $expected $actual
+    if [ $? -ne 0 ]; then
+        failed=$((failed + 1))
+    fi
+}
+
+# Make a draft file forwarding two messages.
+mkdraft() {
+    cat > $draft <<EOF
+From: Mr Foo Bar <foobar@example.com>
+To: Somebody <somebody@example.com>
+Subject: This is รค test
+
+This is a test
+EOF
+}
+
+# Munge the Content-Id from the draft after mhbuild, so we have a reliable
+# value to check.
+mungedraft() {
+    sed 's/\(Content-ID:\) <[^>][^>]*>/\1 <TESTID>/' $draft > $actual
+}
+
+draft=$MH_TEST_DIR/$$.draft
+expected=$MH_TEST_DIR/$$.expected
+actual=$MH_TEST_DIR/$$.actual
+
+# check mhbuild
+cat > $expected <<EOF
+From: Mr Foo Bar <foobar@example.com>
+To: Somebody <somebody@example.com>
+Subject: =?UTF-8?Q?This_is_=C3=A4_test?=
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Content-ID: <TESTID>
+
+This is a test
+EOF
+mkdraft
+mhbuild $draft
+mungedraft
+check
+
+exit $failed