2
1
mirror of https://github.com/kdabir/has.git synced 2024-11-10 21:26:50 +01:00
has/.hastest.bats
2017-08-29 09:18:13 +05:30

31 lines
704 B
Bash

#!/usr/bin/env bats
@test "works with single command check" {
run bash has git
[ "$status" -eq 0 ]
[[ $output == *"✔ git"* ]]
}
@test "safely tells about tools not configured" {
run bash has something-missing
[ "$status" -eq 1 ]
[[ $output == *"✘ something-missing not understood"* ]]
}
@test "env var lets override safety check" {
HAS_ALLOW_UNSAFE=y run bash has something-missing
[ "$status" -eq 1 ]
[[ $output == *"✘ something-missing"* ]]
}
@test "status code reflect number of failed commands" {
HAS_ALLOW_UNSAFE=y run bash has something-missing make git foobar
[ "$status" -eq 2 ]
[[ $output == *"✘ something-missing"* ]]
[[ $output == *"✘ foobar"* ]]
}