Skip to content

Commit

Permalink
test/errors.bats: pass as root
Browse files Browse the repository at this point in the history
The tests need to be skipped when running as root, so let's skip them
conditionally.

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Jul 9, 2024
1 parent da4ebf4 commit eb7868b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/errors.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ load helpers
WONLY_FILE=test/search_files/wonly.txt

function setup() {
if is_root; then
skip "Requires running as non-root"
fi
touch $WONLY_FILE
chmod 200 $WONLY_FILE
}

function teardown() {
rm $WONLY_FILE
rm -f $WONLY_FILE
}

@test "Search with permission error" {
Expand Down
4 changes: 4 additions & 0 deletions test/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ function run_vgrep() {
echo "-------------"
fi
}

function is_root() {
[ "$(id -u)" -eq 0 ]
}

0 comments on commit eb7868b

Please sign in to comment.