Fix WIKIROOT env var tests

Fixed tests using new file structure for personal environment variables.
Added test cases for library environment variable and bibtex (default)
reference file variable.
This commit is contained in:
Marty Oehme 2019-12-28 10:24:56 +01:00
parent bd96394d67
commit bc4b416f53
2 changed files with 48 additions and 6 deletions

View file

@ -3,9 +3,9 @@
# important directories
# will be picked up by vim wiki plugin as root directory
export WIKIROOT="$HOME/documents/notes/"
export LIBRARYROOT="$HOME/documents/library"
export BIBFILE="$LIBRARYROOT/academia/academia.bib"
export WIKIROOT="${WIKIROOT:-$HOME/documents/notes/}"
export LIBRARYROOT="${LIBRARYROOT:-$HOME/documents/library/}"
export BIBFILE="${BIBFILE:-$LIBRARYROOT/academia/academia.bib}"
# these are my personal 'important' environment settings
export EDITOR=nvim

View file

@ -1,9 +1,16 @@
# FIXME why is one saved with trailing "/" , the other not?
DEFAULT_NOTES="$HOME/documents/notes/"
DEFAULT_LIB="$HOME/documents/library"
DEFAULT_BIB="$DEFAULT_LIB/academia/academia.bib"
setup() {
testfile="$BATS_TEST_DIRNAME/../env-wiki-root.sh"
testfile="$BATS_TEST_DIRNAME/../env-vars.sh"
}
teardown() {
export WIKIROOT=""
unset WIKIROOT
unset LIBRARYROOT
unset BIBFILE
}
@test "Populates WIKIROOT environment variable" {
@ -13,7 +20,8 @@ teardown() {
@test "Sets WIKIROOT to correct default path" {
source $testfile
[ "$WIKIROOT" = "$HOME/documents/notes" ]
echo $WIKIROOT
[ "$WIKIROOT" = "$DEFAULT_NOTES" ]
}
@test "Leaves WIKIROOT as is if it is already set" {
@ -21,3 +29,37 @@ teardown() {
source $testfile
[ "$WIKIROOT" = "MY/CUSTOM/DIR" ]
}
@test "Populates LIBRARYROOT environment variable" {
source $testfile
[ -n "$LIBRARYROOT" ]
}
@test "Sets LIBRARYROOT to correct default path" {
source $testfile
echo $LIBRARYROOT
[ "$LIBRARYROOT" = "$DEFAULT_LIB" ]
}
@test "Leaves LIBRARYROOT as is if it is already set" {
export LIBRARYROOT="MY/CUSTOM/DIR"
source $testfile
[ "$LIBRARYROOT" = "MY/CUSTOM/DIR" ]
}
@test "Populates BIBFILE environment variable" {
source $testfile
[ -n "$BIBFILE" ]
}
@test "Sets BIBFILE to correct default path" {
source $testfile
echo $BIBFILE
[ "$BIBFILE" = "$DEFAULT_BIB" ]
}
@test "Leaves BIBFILE as is if it is already set" {
export BIBFILE="MY/CUSTOM/DIR"
source $testfile
[ "$BIBFILE" = "MY/CUSTOM/DIR" ]
}