test_extract_failed_ids.bats 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. setup() {
  2. load ./test_helper/bats-support/load
  3. load ./test_helper/bats-assert/load
  4. }
  5. teardown() {
  6. rm -f failed.txt
  7. }
  8. @test "fail run no logfile" {
  9. run ../extract_failed_ids.sh
  10. assert_failure
  11. }
  12. @test "fail no downloader module" {
  13. run ../extract_failed_ids.sh ./example_logfiles/failed_no_downloader.txt
  14. echo "$output" > failed.txt
  15. assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "3" ];
  16. assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ];
  17. }
  18. @test "fail resource error" {
  19. run ../extract_failed_ids.sh ./example_logfiles/failed_resource_error.txt
  20. echo "$output" > failed.txt
  21. assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "1" ];
  22. assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ];
  23. }
  24. @test "fail site downloader error" {
  25. run ../extract_failed_ids.sh ./example_logfiles/failed_sitedownloader_error.txt
  26. echo "$output" > failed.txt
  27. assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "2" ];
  28. assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ];
  29. }
  30. @test "fail failed file write" {
  31. run ../extract_failed_ids.sh ./example_logfiles/failed_write_error.txt
  32. echo "$output" > failed.txt
  33. assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "1" ];
  34. assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ];
  35. }
  36. @test "fail disabled module" {
  37. run ../extract_failed_ids.sh ./example_logfiles/failed_disabled_module.txt
  38. echo "$output" > failed.txt
  39. assert [ "$( wc -l 'failed.txt' | awk '{ print $1 }' )" -eq "1" ];
  40. assert [ "$( grep -Ecv '\w{6,7}' 'failed.txt' )" -eq "0" ];
  41. }