Skip to content

Commit 3d5d97e

Browse files
committed
use bats-assert instead of embedded helpers
1 parent d08c588 commit 3d5d97e

File tree

4 files changed

+12
-44
lines changed

4 files changed

+12
-44
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"devDependencies": {
3838
"@nodenv/nodenv": "^1.1.2",
3939
"bats": "^0.4.2",
40+
"bats-assert": "^1.1.1",
4041
"brew-publish": "^2.3.1"
4142
},
4243
"dependencies": {

test/nodenv-package-json-engine.bats

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env bats
2-
# Tests of basic usage and functionality
32

43
load test_helper
54

test/test_helper.bash

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# shellcheck shell=bash
22

3-
unset NODENV_VERSION
4-
5-
EXAMPLE_PACKAGE_DIR="$BATS_TMPDIR/example_package"
3+
load ../node_modules/bats-assert/all
64

75
setup() {
6+
unset NODENV_VERSION
7+
8+
EXAMPLE_PACKAGE_DIR="$BATS_TMPDIR/example_package"
9+
810
export NODENV_ROOT="$BATS_TMPDIR/nodenv_root"
911

1012
PATH="$(npm bin):/usr/bin:/bin:/usr/sbin:/sbin"
@@ -19,38 +21,6 @@ teardown() {
1921
rm -r "$NODENV_ROOT"
2022
}
2123

22-
assert() {
23-
if ! "$@"; then
24-
flunk "failed: $*"
25-
fi
26-
}
27-
28-
assert_equal() {
29-
if [ "$1" != "$2" ]; then
30-
{ echo "expected: $1"
31-
echo "actual: $2"
32-
} | flunk
33-
fi
34-
}
35-
36-
assert_output() {
37-
local expected
38-
if [ $# -eq 0 ]; then expected="$(cat -)"
39-
else expected="$1"
40-
fi
41-
# shellcheck disable=SC2154
42-
assert_equal "$expected" "$output"
43-
}
44-
45-
assert_success() {
46-
# shellcheck disable=SC2154
47-
if [ "$status" -ne 0 ]; then
48-
flunk "command failed with exit status $status"
49-
elif [ "$#" -gt 0 ]; then
50-
assert_output "$1"
51-
fi
52-
}
53-
5424
# cd_into_package nodeVersion [extraArgs]
5525
cd_into_package() {
5626
mkdir -p "$EXAMPLE_PACKAGE_DIR"
@@ -87,11 +57,3 @@ create_version() {
8757
mkdir -p "$d"
8858
ln -s /bin/echo "$d/node"
8959
}
90-
91-
flunk() {
92-
{ if [ "$#" -eq 0 ]; then cat -
93-
else echo "$@"
94-
fi
95-
} >&2
96-
return 1
97-
}

0 commit comments

Comments
 (0)