From f236aef565c1f9c99dcf24979830b232ab6749bc Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 17 Apr 2021 14:06:10 +0300 Subject: rewrite in rust --- clab.yarn | 133 -------------------------------------------------------------- 1 file changed, 133 deletions(-) delete mode 100644 clab.yarn (limited to 'clab.yarn') 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" -- cgit v1.2.1