Merge branch '47-add-unit-testing-to-sh-zsh-bash-files' into 'master'

Resolve "Add unit testing to SH/ZSH/Bash files"

Closes #47

See merge request marty-oehme/dotfiles!17
This commit is contained in:
Marty Oehme 2019-07-27 11:42:54 +00:00
commit c8cd9bf11e
5 changed files with 50 additions and 1 deletions

View file

@ -64,6 +64,7 @@ Plug 'stephpy/vim-yaml'
Plug 'mhartington/nvim-typescript', {'for': 'typescript','do': './install.sh'}
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
Plug 'aliou/bats.vim'
" HTML Workflow
Plug 'valloric/matchtagalways', { 'on': [] }

View file

@ -2,4 +2,4 @@
# set wiki root to nextcloud notes folder,
# will be picked up by vim wiki plugin as root
export WIKIROOT="$HOME/Nextcloud/Notes/"
export WIKIROOT=${WIKIROOT:-"$HOME/Nextcloud/Notes/"}

View file

@ -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" ]
}

View file

@ -0,0 +1,15 @@
setup() {
testfile="$BATS_TEST_DIRNAME/../locale-utf-8.sh"
}
teardown() {
export LC_ALL=""
export LANG=""
}
@test "Sets LC_ALL and LANG to en_US.utf-8" {
source $testfile
expected="en_US.utf-8"
[ "$LC_ALL" = "en_US.utf-8" ]
[ "$LANG" = "en_US.utf-8" ]
}

View file

@ -24,3 +24,13 @@ lint:
- find . -type f -name '*.sh' | xargs shfmt -d -i 2
- echo "--------- CHECKING ZSH SHELLSCRIPTS -------------"
- find . -type f -name '*.zsh' | xargs shfmt -d -i 2
test:
stage: test
image: alpine
before_script:
- apk add git bash
- git clone https://github.com/bats-core/bats-core.git /bats
- /bats/bin/bats --version
script:
- /bats/bin/bats -r .