dotfiles/.config/shell/login.d/test/env-wiki-root.bats
Marty Oehme bc4b416f53 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.
2019-12-28 11:16:14 +01:00

65 lines
1.4 KiB
Bash

# 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-vars.sh"
}
teardown() {
unset WIKIROOT
unset LIBRARYROOT
unset BIBFILE
}
@test "Populates WIKIROOT environment variable" {
source $testfile
[ -n "$WIKIROOT" ]
}
@test "Sets WIKIROOT to correct default path" {
source $testfile
echo $WIKIROOT
[ "$WIKIROOT" = "$DEFAULT_NOTES" ]
}
@test "Leaves WIKIROOT as is if it is already set" {
export WIKIROOT="MY/CUSTOM/DIR"
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" ]
}