-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:added tests for pre-exit hook (#10)
- Loading branch information
1 parent
6b7f0ec
commit d83d5f8
Showing
2 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bats | ||
|
||
load "$BATS_PLUGIN_PATH/load.bash" | ||
|
||
@test "Ensure TMP_DIR is not removed if it existed before" { | ||
export TMP_DIR=$(mktemp -d) | ||
|
||
run "${PWD}/hooks/pre-exit" | ||
|
||
assert_success | ||
assert_output --partial "Not removing given TMP_DIR (${TMP_DIR})" | ||
|
||
rm -rf "$TMP_DIR" | ||
unset TMP_DIR | ||
} | ||
|
||
@test "Ensure TMP_DIR is removed if didnt exist" { | ||
run "${PWD}/hooks/pre-exit" | ||
assert_success | ||
assert_output --partial "Removing TMP_DIR" | ||
} | ||
|
||
@test "Ensure tunnel is stopped" { | ||
export TMP_DIR=$(mktemp -d) | ||
touch "${TMP_DIR}/pid.$$" | ||
|
||
run "${PWD}/hooks/pre-exit" | ||
|
||
assert_success | ||
assert_output --partial "Stopping LambdaTest Tunnel" | ||
assert_output --partial "Tunnel Successfully Stopped" | ||
|
||
|
||
unset TMP_DIR | ||
rm -rf "$TMP_DIR" | ||
} |