Remove the assert in CommitData.parse() function
[stgit] / t / t1900-mail.sh
index e83b2d3..acb61a7 100755 (executable)
@@ -6,11 +6,11 @@ test_description='Test the mail command'
 test_expect_success \
     'Initialize the StGIT repository' \
     '
-    git repo-config stgit.sender "A U Thor <author@example.com>" &&
+    git config stgit.sender "A U Thor <author@example.com>" &&
     for i in 1 2 3 4 5; do
       touch foo.txt &&
       echo "line $i" >> foo.txt &&
-      git add foo.txt &&
+      stg add foo.txt &&
       git commit -a -m "Patch $i"
     done &&
     stg init &&
@@ -47,4 +47,37 @@ test_expect_success \
     [ "$t1" = "$t2" ]
     '
 
+test_expect_success \
+    'Check the To:, Cc: and Bcc: headers' \
+    '
+    stg mail --to=a@a --cc="b@b, c@c" --bcc=d@d $(stg top) -m \
+        -t ../../templates/patchmail.tmpl > mbox &&
+    test "$(cat mbox | grep -e "^To:")" = "To: a@a" &&
+    test "$(cat mbox | grep -e "^Cc:")" = "Cc: b@b, c@c" &&
+    test "$(cat mbox | grep -e "^Bcc:")" = "Bcc: d@d"
+    '
+
+test_expect_success \
+    'Check the --auto option' \
+    '
+    stg edit --sign &&
+    stg mail --to=a@a --cc="b@b, c@c" --bcc=d@d --auto $(stg top) -m \
+        -t ../../templates/patchmail.tmpl > mbox &&
+    test "$(cat mbox | grep -e "^To:")" = "To: a@a" &&
+    test "$(cat mbox | grep -e "^Cc:")" = \
+        "Cc: C O Mitter <committer@example.com>, b@b, c@c" &&
+    test "$(cat mbox | grep -e "^Bcc:")" = "Bcc: d@d"
+    '
+
+test_expect_success \
+    'Check the e-mail address duplicates' \
+    '
+    stg mail --to="a@a, b b <b@b>" --cc="b@b, c@c" \
+        --bcc="c@c, d@d, committer@example.com" --auto $(stg top) -m \
+        -t ../../templates/patchmail.tmpl > mbox &&
+    test "$(cat mbox | grep -e "^To:")" = "To: b b <b@b>, a@a" &&
+    test "$(cat mbox | grep -e "^Cc:")" = "Cc: c@c" &&
+    test "$(cat mbox | grep -e "^Bcc:")" = "Bcc: committer@example.com, d@d"
+    '
+
 test_done