2
1
mirror of https://github.com/kdabir/has.git synced 2024-09-18 17:01:29 +02:00
has/.hastest.bats

31 lines
639 B
Plaintext
Raw Normal View History

2017-08-28 18:07:44 +02:00
#!/usr/bin/env bats
@test "works with single command check" {
run bash has git
2017-08-28 18:07:44 +02:00
[ "$status" -eq 0 ]
[[ $output == *"✔ git"* ]]
2017-08-28 18:07:44 +02:00
}
@test "safely tells about tools not configured" {
2017-08-29 05:53:21 +02:00
run bash has foobar
2017-08-28 18:07:44 +02:00
[ "$status" -eq 1 ]
2017-08-29 05:53:21 +02:00
[[ $output == *"✘ foobar not understood"* ]]
2017-08-28 18:07:44 +02:00
}
@test "env var lets override safety check" {
2017-08-29 05:53:21 +02:00
HAS_ALLOW_UNSAFE=y run bash has foobar
2017-08-28 18:07:44 +02:00
[ "$status" -eq 1 ]
2017-08-29 05:53:21 +02:00
[[ $output == *"✘ foobar"* ]]
2017-08-28 18:07:44 +02:00
}
2017-08-29 05:48:13 +02:00
2017-08-29 05:53:21 +02:00
@test "status code reflects number of failed commands" {
HAS_ALLOW_UNSAFE=y run bash has foobar make git barbaz
2017-08-29 05:48:13 +02:00
[ "$status" -eq 2 ]
[[ $output == *"✘ foobar"* ]]
2017-08-29 05:53:21 +02:00
[[ $output == *"✘ barbaz"* ]]
2017-08-29 05:48:13 +02:00
}