Add bash/error-handling

This commit is contained in:
dwrz
2019-06-28 08:24:57 +00:00
parent e9702c608f
commit 7f063b445c
3 changed files with 101 additions and 0 deletions
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
@test "correct arguments" {
run bash error_handling.sh Alice
[ "$status" -eq 0 ]
[ "$output" = "Hello, Alice" ]
}
@test "one long argument" {
run bash error_handling.sh "Alice and Bob"
[ "$status" -eq 0 ]
[ "$output" = "Hello, Alice and Bob" ]
}
@test "incorrect arguments" {
run bash error_handling.sh Alice Bob
[ "$status" -eq 1 ]
[ "$output" = "Usage: ./error_handling <greetee>" ]
}
@test "print usage banner with no value given" {
run bash error_handling.sh
[ "$status" -eq 1 ]
[ "$output" = "Usage: ./error_handling <greetee>" ]
}
@test "empty argument" {
run bash error_handling.sh ""
[ "$status" -eq 0 ]
[ "$output" = "Hello, " ]
}