test_main 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bash
  2. set -e
  3. set -u
  4. set -o pipefail
  5. source "${BASH_SOURCE%/*}/assertions.sh"
  6. source "${BASH_SOURCE%/*}/../src/site/build_site.sh"
  7. source "${BASH_SOURCE%/*}/../src/main_function.sh"
  8. test_build_main_mocked_including_some_coreutils() {
  9. source "${BASH_SOURCE%/*}/mocks/coreutils/cd"
  10. source "${BASH_SOURCE%/*}/mocks/coreutils/pwd"
  11. source "${BASH_SOURCE%/*}/mocks/fenrisg/get_absolute_path.sh"
  12. source "${BASH_SOURCE%/*}/mocks/fenrisg/get_date_stamp.sh"
  13. source "${BASH_SOURCE%/*}/mocks/fenrisg/get_git_branch.sh"
  14. source "${BASH_SOURCE%/*}/mocks/fenrisg/get_git_commit_id.sh"
  15. source "${BASH_SOURCE%/*}/mocks/fenrisg/get_git_commit_id_short.sh"
  16. source "${BASH_SOURCE%/*}/mocks/fenrisg/get_version.sh"
  17. source "${BASH_SOURCE%/*}/mocks/fenrisg/process_file.sh"
  18. build_site \
  19. "0" \
  20. "a" \
  21. "b" \
  22. "c" \
  23. "d" \
  24. "e" \
  25. "f" \
  26. > /dev/null
  27. assert_exit_status \
  28. "test_build_main_mocked_including_some_coreutils" \
  29. 0 \
  30. $?
  31. }
  32. test_fenrisg_main_help() {
  33. source "${BASH_SOURCE%/*}/../src/usage.sh"
  34. fenrisg_main "-h" > /dev/null
  35. assert_exit_status \
  36. "test_build_main_version" \
  37. 0 \
  38. $?
  39. }
  40. test_fenrisg_main_version() {
  41. source "${BASH_SOURCE%/*}/mocks/fenrisg/get_version.sh"
  42. fenrisg_main "-v" > /dev/null
  43. assert_exit_status \
  44. "test_build_main_version" \
  45. 0 \
  46. $?
  47. }
  48. test_main_main() {
  49. test_build_main_mocked_including_some_coreutils
  50. test_fenrisg_main_help
  51. test_fenrisg_main_version
  52. }
  53. test_main_main