diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-07-15 21:14:53 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-07-15 21:14:53 +0100 |
commit | 512c1b7b263136fe2fd9d3422e4faf4cb71a7188 (patch) | |
tree | 09e360db0d6fe546f2709e126df34d6c09290005 | |
parent | e0006b8da257a7dd4efd24aceb5972f4d1781936 (diff) | |
download | clab-512c1b7b263136fe2fd9d3422e4faf4cb71a7188.tar.gz |
Add yarn tests for clab
-rw-r--r-- | clab.yarn | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/clab.yarn b/clab.yarn new file mode 100644 index 0000000..2475936 --- /dev/null +++ b/clab.yarn @@ -0,0 +1,83 @@ +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 + +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 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 not found + ! grep -F "$MATCH_1" "$DATADIR/output" |