Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
Add test harness for various library loading methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnn committed Mar 22, 2017
1 parent 3847b01 commit d8d52e7
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/fixtures/bats/load.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
[ -n "$HELPER_NAME" ] || HELPER_NAME="test_helper"
load "$HELPER_NAME"

BATS_LIB_PATH="$BATS_TEST_DIRNAME/load_path" \
load "${HELPER_LIB_SINGLE_FILE:-single_file}"

BATS_LIB_PATH="$BATS_TEST_DIRNAME/load_path" \
load "${HELPER_LIB_NO_LOADER:-no_loader}"

BATS_LIB_PATH="$BATS_TEST_DIRNAME/load_path" \
load "${HELPER_LIB_WITH_LOADER:-with_loader}"

@test "calling a loaded helper" {
help_me
}

@test "calling a library helper" {
lib_func
}

@test "calling a helper from library without loading file" {
no_loader
}

@test "calling a helper from library with loading file" {
with_loader
}
3 changes: 3 additions & 0 deletions test/fixtures/bats/load_path/no_loader/no_loader.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
no_loader() {
true
}
3 changes: 3 additions & 0 deletions test/fixtures/bats/load_path/single_file.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib_func() {
true
}
1 change: 1 addition & 0 deletions test/fixtures/bats/load_path/with_loader.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source "$(dirname ${BASH_SOURCE[0]})/with_loader/a-file.bash"
3 changes: 3 additions & 0 deletions test/fixtures/bats/load_path/with_loader/a-file.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
with_loader() {
true
}

0 comments on commit d8d52e7

Please sign in to comment.