summaryrefslogtreecommitdiff
path: root/clab.yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-17 14:06:10 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-17 15:53:21 +0300
commitf236aef565c1f9c99dcf24979830b232ab6749bc (patch)
tree0d1053ad8ef0b6f7de9a74485b641b81dd85c0c4 /clab.yarn
parente325fc5e47e5ef34969a30fc6568a58a6026f39b (diff)
downloadclab-f236aef565c1f9c99dcf24979830b232ab6749bc.tar.gz
rewrite in rust
Diffstat (limited to 'clab.yarn')
-rw-r--r--clab.yarn133
1 files changed, 0 insertions, 133 deletions
diff --git a/clab.yarn b/clab.yarn
deleted file mode 100644
index 745eb09..0000000
--- a/clab.yarn
+++ /dev/null
@@ -1,133 +0,0 @@
-Black box tests for clab
-========================
-
-Clab is a command line address book application.
-It has no interactive features, so black box testing it
-is fairly easy.
-
-Let's start with an empty database.
-
- SCENARIO empty database
- GIVEN an empty database
-
- WHEN listing all records
- THEN nothing is listed
-
- WHEN searching for Alice
- THEN output is empty
-
- WHEN mutt-querying for Alice
- THEN no matches
-
-Next, let's add records for Alice and Bob, and make
-sure searches find only the right records.
-
- SCENARIO database with records
- GIVEN an empty database
- AND a record for "Alice Atherton" with e-mail alice@example.com
- AND a record for "Bob Bobbington" with e-mail bob@example.com
-
- WHEN listing all records
- THEN Alice is found
- AND Bob is found
-
- WHEN searching for Alice
- THEN Alice is found
- AND Bob is not found
-
- WHEN mutt-querying for Alice
- THEN Alice is found
- AND alice@example.com is found
- AND Bob is not found
- AND bob@example.com is not found
-
-Put several records in one file.
-
- SCENARIO files with multiple records
- GIVEN an empty database
- AND records for Alice (alice@example.com) and Bob (bob@example.com)
- WHEN listing all records
- THEN Alice is found
- AND Bob is found
-
- WHEN searching for Alice
- THEN Alice is found
- AND Bob is not found
-
- WHEN mutt-querying for Alice
- THEN Alice is found
- AND alice@example.com is found
- 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
---------------
-
-These implement the various steps.
-
- IMPLEMENTS GIVEN an empty database
- mkdir "$DATADIR/db"
-
- IMPLEMENTS GIVEN a record for "([^"]+)" with e-mail (.*)
- cat << EOF > "$DATADIR/db/$MATCH_1.yaml"
- name: $MATCH_1
- email: $MATCH_2
- EOF
-
- IMPLEMENTS GIVEN records for (\S+) \((\S+)\) and (\S+) \((\S+)\)
- cat << EOF > "$DATADIR/db/foo.yaml"
- - name: $MATCH_1
- email: $MATCH_2
- - name: $MATCH_3
- 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"
-
- IMPLEMENTS WHEN searching for (.*)
- ./clab --no-default-config --db "$DATADIR/db" find "$MATCH_1" > "$DATADIR/output"
-
- IMPLEMENTS WHEN mutt-querying for (.*)
- ./clab --no-default-config --db "$DATADIR/db" mutt-query "$MATCH_1" > "$DATADIR/output" || true
-
- IMPLEMENTS THEN nothing is listed
- stat -c %s "$DATADIR/output" | grep -x 0
-
- IMPLEMENTS THEN output is empty
- stat -c %s "$DATADIR/output" | grep -x 0
-
- IMPLEMENTS THEN no matches
- diff -u "$DATADIR/output" - << EOF
- No matches
- EOF
-
- IMPLEMENTS THEN (.*) is found
- 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"