Skip to content

Commit 14e8f59

Browse files
committed
Add tests for NOTES_DIRECTORY configuration
1 parent aa0c1b7 commit 14e8f59

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/test-config.bats

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,21 @@ notes="./notes"
4242
assert_success
4343
assert_exists "$NOTES_DIRECTORY/test.txt"
4444
}
45+
46+
@test "Configuration should be accepted if NOTES_DIR doesn't exist" {
47+
mkdir -p $HOME/.config/notes
48+
echo "NOTES_DIRECTORY=$NOTES_DIRECTORY/notesdir" > $HOME/.config/notes/config
49+
run $notes new test
50+
51+
assert_success
52+
}
53+
54+
@test "Configuration should be rejected if NOTES_DIR is a existing file" {
55+
mkdir -p $HOME/.config/notes
56+
touch $NOTES_DIRECTORY/testfile
57+
echo "NOTES_DIRECTORY=$NOTES_DIRECTORY/testfile" > $HOME/.config/notes/config
58+
run $notes new test
59+
60+
assert_failure
61+
assert_line "Could not create directory $NOTES_DIRECTORY/testfile, please update your \$NOTES_DIRECTORY"
62+
}

0 commit comments

Comments
 (0)