Exercism: Bash version of the 'Error Handling' exercise.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
940 B

3 years ago
  1. #!/usr/bin/env bash
  2. # local version: 0.0.1
  3. @test "correct arguments" {
  4. #[[ $BATS_RUN_SKIPPED == "true" ]] || skip
  5. run bash error_handling.sh Alice
  6. (( status == 0 ))
  7. [[ $output == "Hello, Alice" ]]
  8. }
  9. @test "one long argument" {
  10. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  11. run bash error_handling.sh "Alice and Bob"
  12. (( status == 0 ))
  13. [[ $output == "Hello, Alice and Bob" ]]
  14. }
  15. @test "incorrect arguments" {
  16. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  17. run bash error_handling.sh Alice Bob
  18. (( status == 1 ))
  19. [[ $output == "Usage: error_handling.sh <person>" ]]
  20. }
  21. @test "print usage banner with no value given" {
  22. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  23. run bash error_handling.sh
  24. (( status == 1 ))
  25. [[ $output == "Usage: error_handling.sh <person>" ]]
  26. }
  27. @test "empty argument" {
  28. [[ $BATS_RUN_SKIPPED == "true" ]] || skip
  29. run bash error_handling.sh ""
  30. (( status == 0 ))
  31. [[ $output == "Hello, " ]]
  32. }