diff options
Diffstat (limited to 'yarns/900-implementations.yarn')
-rw-r--r-- | yarns/900-implementations.yarn | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/yarns/900-implementations.yarn b/yarns/900-implementations.yarn new file mode 100644 index 0000000..35398a6 --- /dev/null +++ b/yarns/900-implementations.yarn @@ -0,0 +1,90 @@ +Implementatios of scenario steps +================================ + +This chapter contains implementations for the various steps used in +the scenarios above. + + +No use of git +------------- + +The test suite won't be using git. Normally `jt` would add new notes +to git, and commit them, but there's no need for that during the test +suite. That part either works or it doesn't, and it's simple enough +that it almost certainly will work. (Go on, make me eat my words.) +However, running git adds more complexity to the test suite, such as +dealing with the git configuration, or lack thereof, of the user +running the test suite. + + +Set up an empty journal +----------------------- + +For tests, we need an empty journal. + + IMPLEMENTS GIVEN an empty journal in (\S+) + mkdir "$DATADIR/$MATCH_1" + cat <<EOF > "$DATADIR/source.conf" + [config] + source = $DATADIR/$MATCH_1 + EOF + + +Keeping time +------------ + +For various things we need to pretend we know what the time is. For +example, we may need to test that a filename is generated correctly +from the current timestamp. Because of this, `jt` has a +`--pretend-time` setting, which we will use extensively in the test +suite. + +Within the test suite we implement this by having a `time.conf` +configuration file, created by a "GIVEN the time is ..." step, and +making sure we give that configuration file to `jt` when it's run by +the test suite. + + IMPLEMENTS GIVEN the time is (\d{4}-\d\d-\d\d \d\d:\d\d:\d\d) + cat <<EOF > "$DATADIR/time.conf" + [config] + pretend-time = $MATCH_1 + EOF + + +Running jt commands +------------------- + +We run `jt` from the source tree, without any configurations from the +user, and with specific settings to make the test suite run smoother. + + IMPLEMENTS WHEN I run jt (.*) + EDITOR=true \ + "$SRCDIR/jt" --no-default-config \ + --config "$DATADIR/source.conf" \ + --config "$DATADIR/time.conf" \ + --layout=pkb \ + --no-git \ + $MATCH_1 + + +Checking file existence +----------------------- + +Does a file exist? + + IMPLEMENTS THEN file (\S+) exists + test -e "$DATADIR/$MATCH_1" + +Does a file _not_ exist? + + IMPLEMENTS THEN file (\S+) doesn't exist + ! test -e "$DATADIR/$MATCH_1" + + +Checking file contents +---------------------- + +Does a file match a regular expression? + + IMPLEMENTS THEN file (\S+) matches (\S+) + grep -e "$MATCH_2" "$DATADIR/$MATCH_1" |