From 08e15dab3ab7143860ecfd113be0e7b8a13c0e69 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 27 Jul 2019 12:38:48 +0200 Subject: [PATCH] Add sample unit tests Two should pass, one should fail --- .config/shell/rc.d/test/env-wiki-root.bats | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .config/shell/rc.d/test/env-wiki-root.bats diff --git a/.config/shell/rc.d/test/env-wiki-root.bats b/.config/shell/rc.d/test/env-wiki-root.bats new file mode 100644 index 0000000..1254e81 --- /dev/null +++ b/.config/shell/rc.d/test/env-wiki-root.bats @@ -0,0 +1,23 @@ +setup() { + testfile="$BATS_TEST_DIRNAME/../env-wiki-root.sh" +} + +teardown() { + export WIKIROOT="" +} + +@test "Populates WIKIROOT environment variable" { + source $testfile + [ -n "$WIKIROOT" ] +} + +@test "Sets WIKIROOT to correct default path" { + source $testfile + [ "$WIKIROOT" = "$HOME/Nextcloud/Notes/" ] +} + +@test "Leaves WIKIROOT as is if it is already set" { + export WIKIROOT="MY/CUSTOM/DIR" + source $testfile + [ "$WIKIROOT" = "MY/CUSTOM/DIR" ] +}