From b4a7b6a1b175c1e3a41e533ce9cfef6d76582243 Mon Sep 17 00:00:00 2001 From: bth Date: Sat, 20 Jan 2024 12:39:09 -0800 Subject: [PATCH] more bats tests --- shell/next.sh | 2 +- shell/test/um.bats | 34 ++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/shell/next.sh b/shell/next.sh index c2d0f96..d637e7b 100755 --- a/shell/next.sh +++ b/shell/next.sh @@ -41,7 +41,7 @@ UMELISP="(progn (find-file \"$NEXTFILE\") (um-journal-header) $UMTAG (message \" # for testing and piping if [ $UMNEXTECHO = true ]; then - echo $NEXTFILE $UMTAG + echo $UMELISP else # HACK: emacs won't accept piped input as a file name, so we use --eval to open # the file via find-file. diff --git a/shell/test/um.bats b/shell/test/um.bats index 234bbde..9f73534 100644 --- a/shell/test/um.bats +++ b/shell/test/um.bats @@ -7,7 +7,8 @@ setup() { # as those will point to the bats executable's location or the preprocessed file respectively DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" # make executables visible to PATH - PATH="$DIR/..:$PATH" + # FIXME: why isn't this working? + # PATH="$DIR/../:$PATH" # commands depend on being in the journal/ path. cd $DIR/mockjournal # so that we can run next.sh without dealing with emacsclient. @@ -24,22 +25,39 @@ teardown() { assert_output 'usage: um (next|last|cat|rename|tag)' } -@test "next empty" { +um_next_awk() { + echo "$1" | awk -f $DIR/../next.awk -v arg="$2" +} + +@test "next.awk" { + run um_next_awk 01.md + assert_output '02.md' + + run um_next_awk 01.md foo + assert_output '02.foo.md' +} + +@test "um next empty" { run um next - assert_output '100.md' + assert_output --partial '100.md' } -@test "next descriptor" { +@test "um next empty elisp" { + run um next + assert_output '(progn (find-file "100.md") (um-journal-header) (message "creating 100.md"))' +} + +@test "um next descriptor" { run um next foo - assert_output '100.foo.md' + assert_output --partial '100.foo.md' } -@test "next descriptor tag" { +@test "um next descriptor tag" { run um next foo bar assert_output --partial '(insert "+ bar\n")' } -@test "next descriptor +" { +@test "um next descriptor +" { run um next foo + assert_output --partial '(insert "+ foo\n")' } @@ -64,7 +82,7 @@ teardown() { um_rename_awk() { echo "$1 -$2" | awk -f ../../rename.awk +$2" | awk -f $DIR/../rename.awk } @test "rename.awk" {