summaryrefslogtreecommitdiff
path: root/yarns
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-11-07 16:49:51 +0000
committerLars Wirzenius <liw@liw.fi>2015-11-07 16:49:51 +0000
commit0c855639dd333ebe196e04b965c9c958e6a2c75e (patch)
treed8444ae1c149b22a789abfb01a33f0f31af258f8 /yarns
parent9893e764ba4b0b361980726f48409c282ea65987 (diff)
downloaddistix-0c855639dd333ebe196e04b965c9c958e6a2c75e.tar.gz
Add test case for importing duplicate mails
Diffstat (limited to 'yarns')
-rw-r--r--yarns/080-import-mail.yarn21
-rw-r--r--yarns/900-implements.yarn19
2 files changed, 40 insertions, 0 deletions
diff --git a/yarns/080-import-mail.yarn b/yarns/080-import-mail.yarn
index ece8843..7c1e24c 100644
--- a/yarns/080-import-mail.yarn
+++ b/yarns/080-import-mail.yarn
@@ -25,6 +25,27 @@ will read the e-mail from its standard input.
THEN attempt succeeded
AND output matches "^[0-9a-f]{32} bar$"
+Import one email twice. It should result in the mail existing only
+once in the ticket.
+
+ SCENARIO import one email twice
+
+ WHEN user attempts to run distix init REPO
+ THEN attempt succeeded
+
+ GIVEN file MAIL1 containing "From: foo@example.com\nSubject: bar\n\nyo\n"
+ WHEN user attempts to run distix import-mail REPO MAIL1
+ THEN attempt succeeded
+ AND everything in REPO is committed to git
+ AND repository REPO has 1 ticket
+ AND repository REPO has one copy of message in MAIL1
+
+ WHEN user attempts to run distix import-mail REPO MAIL1
+ THEN attempt succeeded
+ AND everything in REPO is committed to git
+ AND repository REPO has 1 ticket
+ AND repository REPO has one copy of message in MAIL1
+
Next, import an mbox.
SCENARIO import mbox
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index 4456803..221ba9e 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -103,6 +103,25 @@ Does a file or directory exist?
test -e "$DATADIR/$MATCH_1"
+Repository/ticket tests
+-----------------------
+
+How many tickets does a repository have?
+
+ IMPLEMENTS THEN repository (\S+) has (\d+) tickets?
+ n="$(ls "$DATADIR/$MATCH_1/tickets" | wc -l)"
+ [ "$n" = "$MATCH_2" ]
+
+How many copies of a given message does a repository have? In any
+tickets?
+
+ IMPLEMENTS THEN repository (\S+) has one copy of message in (\S+)
+ find "$DATADIR/$MATCH_1/tickets" -type f -exec md5sum '{}' + \
+ > "$DATADIR/md5sums"
+ msgsum="$(md5sum < "$DATADIR/$MATCH_2" | awk '{ print $1 }')"
+ n="$(grep -c -e "$msgsum" "$DATADIR/md5sums" | wc -l)"
+ [ "$n" = 1 ]
+
Git operations
--------------