mirror of https://github.com/Bunsly/JobSpy
add error field test
parent
1f29b78d2f
commit
bb3087c3a1
|
@ -1,9 +1,9 @@
|
||||||
name: Test API
|
name: JobSpy API Tests
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test_returned_results:
|
test_api:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
@ -39,7 +39,7 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Verify results count
|
- name: Check HTTP status to POST /api/v1/jobs/
|
||||||
run: |
|
run: |
|
||||||
response=$(curl -L -s -X 'POST' -H 'Content-Type: application/json' -d '{
|
response=$(curl -L -s -X 'POST' -H 'Content-Type: application/json' -d '{
|
||||||
"site_type": ["indeed", "linkedin", "zip_recruiter"],
|
"site_type": ["indeed", "linkedin", "zip_recruiter"],
|
||||||
|
@ -59,13 +59,32 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${response::-3}" > response.json
|
echo "${response::-3}" > response.json
|
||||||
|
|
||||||
cat response.json
|
cat response.json
|
||||||
|
|
||||||
if [[ $indeed.returned_results -ne 5 || $linkedin.returned_results -ne 5 || $zip_recruiter.returned_results -ne 5 ]]; then
|
- name: Check error field in response
|
||||||
echo "Mismatch in results_wanted and returned_results:"
|
run: |
|
||||||
echo "Indeed: Expected 5, Got $indeed.returned_results"
|
indeed_error=$(jq '.indeed.error' response.json)
|
||||||
echo "LinkedIn: Expected 5, Got $linkedin.returned_results"
|
linkedin_error=$(jq '.linkedin.error' response.json)
|
||||||
echo "ZipRecruiter: Expected 5, Got $zip_recruiter.returned_results"
|
zip_recruiter_error=$(jq '.zip_recruiter.error' response.json)
|
||||||
|
|
||||||
|
if [[ "$indeed_error" != "null" || "$linkedin_error" != "null" || "$zip_recruiter_error" != "null" ]]; then
|
||||||
|
echo "Error found in response:"
|
||||||
|
echo "Indeed Error: $indeed_error"
|
||||||
|
echo "LinkedIn Error: $linkedin_error"
|
||||||
|
echo "ZipRecruiter Error: $zip_recruiter_error"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Verify returned_results in response
|
||||||
|
run: |
|
||||||
|
indeed_results=$(jq '.indeed.returned_results' response.json)
|
||||||
|
linkedin_results=$(jq '.linkedin.returned_results' response.json)
|
||||||
|
zip_recruiter_results=$(jq '.zip_recruiter.returned_results' response.json)
|
||||||
|
|
||||||
|
if [[ $indeed_results -ne 5 || $linkedin_results -ne 5 || $zip_recruiter_results -ne 5 ]]; then
|
||||||
|
echo "Mismatch in results_wanted and returned_results:"
|
||||||
|
echo "Indeed: Expected 5, Got $indeed_results"
|
||||||
|
echo "LinkedIn: Expected 5, Got $linkedin_results"
|
||||||
|
echo "ZipRecruiter: Expected 5, Got $zip_recruiter_results"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
Loading…
Reference in New Issue