Skip to content

Commit

Permalink
Validate raw_output against the output schema, even if unstructured d…
Browse files Browse the repository at this point in the history
…ata.
  • Loading branch information
blambeau committed Jun 6, 2024
1 parent 9e34d75 commit ee795d2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
conditions who want to execute a test case they have. Alternative to
find_and_call.

* Bug fix: validate output schema against the raw output when output
is not "structured" (e.g. application/json) but pure text
(e.g. `text/plain`, `text/csv`). Otherwise using String(s | ... ) has
no effect.

## 0.26.0 - 2023-06-23

* Upgrade runtime and devel dependencies, notably http (5.x) and
Expand Down
7 changes: 5 additions & 2 deletions lib/webspicy/tester/result/error_schema_met.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ def must?
end

def call
return unless invocation.is_structured_output?
output = invocation.loaded_body
output = if invocation.is_structured_output?
invocation.loaded_body
else
invocation.raw_output
end
service.error_schema.dress(output)
rescue Finitio::TypeError => ex
_! "Invalid error: #{ex.message}"
Expand Down
7 changes: 5 additions & 2 deletions lib/webspicy/tester/result/output_schema_met.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ def must?
end

def call
return unless invocation.is_structured_output?
output = invocation.loaded_body
output = if invocation.is_structured_output?
invocation.loaded_body
else
invocation.raw_output
end
service.output_schema.dress(output)
rescue Finitio::TypeError => ex
_! "Invalid output: #{ex.message}"
Expand Down

0 comments on commit ee795d2

Please sign in to comment.