Skip to content

Commit

Permalink
Fix tests/impl to support mock environment.
Browse files Browse the repository at this point in the history
* Check if $USER is defined in clrtrust and skip checks if not.
* Skip tests relying on $USER in mock env.
  • Loading branch information
busykai committed Dec 22, 2017
1 parent a089fed commit de744be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clrtrust
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ cmd_check() {
usr=${USER}
fi

if [ -z ${usr} ]; then
# this is most likely means mock build, but even if not the checks below
# do not apply if the variable is not set
return 0
fi

stat=($(stat -L -c "0%a %G %U" "$dir"))
if [ $? -ne 0 ]; then
return $EERR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ setup() {
}

@test "check fails when trust store cannot be written" {
if [ -z "${USER}" ]; then
skip "mock chroot environment. \$USER is not defined."
fi
run $CLRTRUST check
[ $status -ne 0 ]
[ -n "$output" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ setup() {
}

@test "check fails when there's no parent for trust store" {
if [ -z "${USER}" ]; then
skip "mock chroot environment. \$USER is not defined."
fi
run $CLRTRUST check
[ $status -ne 0 ]
[ -n "$output" ]
Expand Down

0 comments on commit de744be

Please sign in to comment.