chiark / gitweb /
stgit.el: Add "d" for a few diff commands, similar to git.el
[stgit] / t / t1900-mail.sh
1 #!/bin/sh
2 # Copyright (c) 2006 Karl Hasselström
3 test_description='Test the mail command'
4 . ./test-lib.sh
5
6 test_expect_success \
7     'Initialize the StGIT repository' \
8     '
9     git config stgit.sender "A U Thor <author@example.com>" &&
10     for i in 1 2 3 4 5; do
11       touch foo.txt &&
12       echo "line $i" >> foo.txt &&
13       git add foo.txt &&
14       git commit -a -m "Patch $i"
15     done &&
16     stg init &&
17     stg uncommit -n 5 foo
18     '
19
20 test_expect_success \
21     'Put all the patches in an mbox' \
22     'stg mail --to="Inge Ström <inge@example.com>" -a -m \
23        -t ../../templates/patchmail.tmpl > mbox0'
24
25 test_expect_success \
26     'Import the mbox and compare' \
27     '
28     t1=$(git cat-file -p $(stg id) | grep ^tree)
29     stg pop -a &&
30     stg import -M mbox0 &&
31     t2=$(git cat-file -p $(stg id) | grep ^tree) &&
32     [ "$t1" = "$t2" ]
33     '
34
35 test_expect_success \
36     'Put all the patches in an mbox with patch attachments' \
37     'stg mail --to="Inge Ström <inge@example.com>" -a -m \
38        -t ../../templates/mailattch.tmpl > mbox1'
39
40 test_expect_success \
41     'Import the mbox containing patch attachments and compare' \
42     '
43     t1=$(git cat-file -p $(stg id) | grep ^tree)
44     stg pop -a &&
45     stg import -M mbox1 &&
46     t2=$(git cat-file -p $(stg id) | grep ^tree) &&
47     [ "$t1" = "$t2" ]
48     '
49
50 test_expect_success \
51     'Check the To:, Cc: and Bcc: headers' \
52     '
53     stg mail --to=a@a --cc="b@b, c@c" --bcc=d@d $(stg top) -m \
54         -t ../../templates/patchmail.tmpl > mbox &&
55     test "$(cat mbox | grep -e "^To:")" = "To: a@a" &&
56     test "$(cat mbox | grep -e "^Cc:")" = "Cc: b@b, c@c" &&
57     test "$(cat mbox | grep -e "^Bcc:")" = "Bcc: d@d"
58     '
59
60 test_expect_success \
61     'Check the --auto option' \
62     '
63     stg edit --sign &&
64     stg mail --to=a@a --cc="b@b, c@c" --bcc=d@d --auto $(stg top) -m \
65         -t ../../templates/patchmail.tmpl > mbox &&
66     test "$(cat mbox | grep -e "^To:")" = "To: a@a" &&
67     test "$(cat mbox | grep -e "^Cc:")" = \
68         "Cc: C O Mitter <committer@example.com>, b@b, c@c" &&
69     test "$(cat mbox | grep -e "^Bcc:")" = "Bcc: d@d"
70     '
71
72 test_expect_success \
73     'Check the e-mail address duplicates' \
74     '
75     stg mail --to="a@a, b b <b@b>" --cc="b@b, c@c" \
76         --bcc="c@c, d@d, committer@example.com" --auto $(stg top) -m \
77         -t ../../templates/patchmail.tmpl > mbox &&
78     test "$(cat mbox | grep -e "^To:")" = "To: b b <b@b>, a@a" &&
79     test "$(cat mbox | grep -e "^Cc:")" = "Cc: c@c" &&
80     test "$(cat mbox | grep -e "^Bcc:")" = "Bcc: committer@example.com, d@d"
81     '
82
83 test_done