mirror of
https://github.com/kdabir/has.git
synced 2024-11-10 21:26:50 +01:00
4d1035e241
Support Colors #12 * added: colors No more echo with variables in them. Think of it like the Holocaust... Never. Again. * update: removed color codes from tests
31 lines
770 B
Bash
31 lines
770 B
Bash
#!/usr/bin/env bats
|
|
|
|
@test "works with single command check" {
|
|
run bash has git
|
|
|
|
[[ "$status" -eq 0 ]]
|
|
[[ "$(echo "${output}" | grep "✔" | grep "git")" ]]
|
|
}
|
|
|
|
@test "safely tells about tools not configured" {
|
|
run bash has foobar
|
|
|
|
[[ "$status" -eq 1 ]]
|
|
[[ "$(echo "${output}" | grep "✘" | grep "foobar not understood")" ]]
|
|
}
|
|
|
|
@test "env var lets override safety check" {
|
|
HAS_ALLOW_UNSAFE=y run bash has foobar
|
|
|
|
[[ "$status" -eq 1 ]]
|
|
[[ "$(echo "${output}" | grep "✘" | grep "foobar")" ]]
|
|
}
|
|
|
|
@test "status code reflects number of failed commands" {
|
|
HAS_ALLOW_UNSAFE=y run bash has foobar bc git barbaz
|
|
|
|
[[ "$status" -eq 2 ]]
|
|
[[ "$(echo "${output}" | grep "✘" | grep "foobar")" ]]
|
|
[[ "$(echo "${output}" | grep "✘" | grep "barbaz")" ]]
|
|
}
|