Add bash/error-handling
This commit is contained in:
@@ -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, " ]
|
||||
}
|
||||
Reference in New Issue
Block a user