diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-12-31 19:35:25 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-12-31 19:35:25 +0200 |
commit | fca27a03e1c404253c80607590e7bfac5af1cbfc (patch) | |
tree | 61e6e5cd5768452fe5291267c47c171326ed9bb7 | |
parent | d342098c512c6664d8d9c39623acb9e572810d02 (diff) | |
download | distix-fca27a03e1c404253c80607590e7bfac5af1cbfc.tar.gz |
Add yarn scenario steps to test "distix show $prefix"
-rw-r--r-- | yarns/040-new.yarn | 8 | ||||
-rw-r--r-- | yarns/900-implements.yarn | 45 |
2 files changed, 52 insertions, 1 deletions
diff --git a/yarns/040-new.yarn b/yarns/040-new.yarn index ae70656..4ee5345 100644 --- a/yarns/040-new.yarn +++ b/yarns/040-new.yarn @@ -22,3 +22,11 @@ We create a new ticket, with a title that contains non-ASCII text. WHEN user attempts to run distix list THEN attempt succeeded AND output matches "^[0-9a-f]{32} .* new-ticket-title-gröt$" + AND first ticket id is captured as $TID + AND ticket id $TID 7-nybble prefix is $PREFIX + +Can we show a ticket using just a prefix of the ticket id? + + WHEN user attempts to run distix show $PREFIX + THEN attempt succeeded + AND output contains ticket id $TID diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn index cbf8ea4..a84f7c8 100644 --- a/yarns/900-implements.yarn +++ b/yarns/900-implements.yarn @@ -22,7 +22,7 @@ be, and changing there when running various commands. IMPLEMENTS WHEN user changes working directory to (\S+) printf "%s" "$MATCH_1" > "$DATADIR/cwd" - IMPLEMENTS WHEN user attempts to run distix (.*) + IMPLEMENTS WHEN user attempts to run distix ([^$]*) # Yarn sets $HOME to point at an empty temporary directory. # Set up a simple git config so tests can use git. @@ -42,6 +42,32 @@ be, and changing there when running various commands. echo "$?" > "$DATADIR/attempt.exit" fi + IMPLEMENTS WHEN user attempts to run distix show \$PREFIX +b + # Yarn sets $HOME to point at an empty temporary directory. + # Set up a simple git config so tests can use git. + git config --global user.email 'Tomjon <tomjon@example.com>' + git config --global user.name 'Tomjon Tester' + + cd "$DATADIR" + rm -f attempt.exit attempt.stdout attempt.stderr + cd "$(cat cwd || echo .)" + if "$SRCDIR/distix" --no-default-config --quiet \ + --log "$DATADIR/distix.log" \ + show "$(cat "$DATADIR/tid-prefix")"\ + > "$DATADIR/attempt.stdout" 2> "$DATADIR/attempt.stderr" + then + echo 0 > "$DATADIR/attempt.exit" + else + echo "$?" > "$DATADIR/attempt.exit" + echo ============= distix stdout + cat "$DATADIR/attempt.stdout" + echo ============= distix stderr + cat "$DATADIR/attempt.stderr" + echo ============= distix output end + fi + exit 1 + IMPLEMENTS WHEN user sets all tickets in (\S+) to (\S+) cd "$DATADIR/$MATCH_1" @@ -86,6 +112,12 @@ distix. exit 1 fi + IMPLEMENTS THEN first ticket id is captured as \$TID + # We assume previous command run was distix list. + # Each line starts with a full ticket id. + head -n1 "$DATADIR/attempt.stdout" | awk '{print $1}' \ + > "$DATADIR/ticket-id-1" + IMPLEMENTS THEN attempt failed cat "$DATADIR/attempt.exit" # helps debugging scenarios if grep -Fx 0 "$DATADIR/attempt.exit" @@ -170,3 +202,14 @@ Check that everything is in git. echo "Not everything is in git" 1>&2 exit 1 fi + + +Ticket id manipulation +---------------------- + + IMPLEMENTS THEN ticket id \$TID 7-nybble prefix is \$PREFIX + cut -c1-7 "$DATADIR/ticket-id-1" > "$DATADIR/tid-prefix" + + IMPLEMENTS THEN output contains ticket id \$TID + grep -f "$DATADIR/ticket-id-1" "$DATADIR/attempt.stdout" + |