Skip to content

Commit

Permalink
Distinguish errors and errors.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Aug 9, 2024
1 parent 3b178c1 commit 8b6352f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tools/src/tester/ChapterEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class ChapterEvaluator {

#evaluate_status(chapter: Chapter, response: ActualResponse): Evaluation {
const expected_status = chapter.response?.status ?? 200
if (response.status === expected_status) return { result: Result.PASSED }
if (response.status === expected_status && response.error === undefined) return { result: Result.PASSED }

let result: Evaluation = {
result: Result.ERROR,
Expand Down
3 changes: 1 addition & 2 deletions tools/src/tester/ChapterReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class ChapterReader {
if (payload !== undefined) response.payload = payload
this.logger.info(`<= ${r.status} (${r.headers['content-type']}) | ${to_json(response.payload)}`)
}).catch(e => {
if (e.response === undefined) {
if (e.response == null) {
this.logger.info(`<= ERROR: ${e}`)
response.message = e.message
response.error = e
Expand All @@ -64,7 +64,6 @@ export default class ChapterReader {
const payload = this.#deserialize_payload(e.response.data, response.content_type)
if (payload !== undefined) response.payload = payload.error
response.message = payload.error?.reason ?? e.response.statusText
response.error = e
this.logger.info(`<= ${response.status} (${response.content_type}) | ${response.payload !== undefined ? to_json(response.payload) : response.message}`)
}
})
Expand Down
1 change: 0 additions & 1 deletion tools/tests/tester/fixtures/evals/error/chapter_error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ chapters:
result: ERROR
message: 'Expected status 200, but received 404: application/json. no such index
[undefined]'
error: Request failed with status code 404
payload_body:
result: SKIPPED
payload_schema:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ prologues:
overall:
result: ERROR
message: no such index [does_not_exists]
error: Request failed with status code 404

chapters:
- title: This chapter be skipped.
Expand Down

0 comments on commit 8b6352f

Please sign in to comment.