From f34f2a23b355f020759f714eb8fb567871de587c Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 5 Oct 2013 13:58:14 +0100 Subject: Output each name/addr only once with mutt-query --- clab.yarn | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'clab.yarn') diff --git a/clab.yarn b/clab.yarn index 234777c..745eb09 100644 --- a/clab.yarn +++ b/clab.yarn @@ -60,6 +60,15 @@ Put several records in one file. AND Bob is not found AND bob@example.com is not found +Sometimes the same person is in the database multiple times +(e.g., different records for home and work personas, where the +work persona is automatically generated from LDAP or something). +In this case, only find each person once. + + GIVEN another record for Alice (alice@example.com) + WHEN mutt-querying for example + THEN Alice is found only once + Implementation -------------- @@ -82,6 +91,12 @@ These implement the various steps. email: $MATCH_4 EOF + IMPLEMENTS GIVEN another record for (\S+) \((\S+)\) + cat << EOF >> "$DATADIR/db/foo.yaml" + - name: $MATCH_1 + email: $MATCH_2 + EOF + IMPLEMENTS WHEN listing all records ./clab --no-default-config --db "$DATADIR/db" list > "$DATADIR/output" @@ -106,5 +121,13 @@ These implement the various steps. set -x grep -F "$MATCH_1" "$DATADIR/output" + IMPLEMENTS THEN (.*) is found only once + n=$(grep -cF "$MATCH_1" "$DATADIR/output") + if [ "$n" != 1 ] + then + echo "$MATCH_1 was found $n times, expected 1" 1>&2 + exit 1 + fi + IMPLEMENTS THEN (.*) is not found ! grep -F "$MATCH_1" "$DATADIR/output" -- cgit v1.2.1