Skip to content

test(bind): add behavioral tests for cwist_bind_write_error_response (#342) - #387

Open
Bhumika-1432006 wants to merge 1 commit into
c4punks:devfrom
Bhumika-1432006:test/342-bind-write-error-response
Open

Bhumika-1432006 wants to merge 1 commit into
c4punks:devfrom
Bhumika-1432006:test/342-bind-write-error-response

Conversation

@Bhumika-1432006

Copy link
Copy Markdown
Contributor

cwist_bind_write_error_response has no direct test; issue #342 lists it under "an error path with no direct test". The existing test_bind.c exercises it only indirectly through the cwist_app_req_bind_json_or_400 convenience wrapper.

What this adds: tests/test_bind_write_error_response.c with four cases:

  • single error: status_code is CWIST_HTTP_BAD_REQUEST, Content-Type is application/json, body contains "success":false and the field and message from the error struct.
  • multiple errors: both field names appear in the body.
  • zero errors: status is still 400, body has an empty errors array.
  • null res: safe no-op, no crash.

How it was verified: the four assertions follow directly from the documented JSON shape in the bind.h header comment for cwist_bind_write_error_response. The test is wired into make test via a new Makefile target.

What it does not do: does not add tests for other uncovered functions in issue #342.

…4punks#342)

cwist_bind_write_error_response has no direct test (issue c4punks#342 lists it
under "cwist_bind_write_error_response -- an error path with no direct
test"). The existing test_bind.c exercises it only indirectly through the
cwist_app_req_bind_json_or_400 convenience wrapper.

This adds tests/test_bind_write_error_response.c with four cases:

- single error: status_code == CWIST_HTTP_BAD_REQUEST, Content-Type is
  application/json, body contains "success":false and the field/message
  from the error struct.
- multiple errors: both field names appear in the body.
- zero errors: status is still 400, body has empty errors array.
- null res: safe no-op (no crash).

The test is wired into make test via a new Makefile target.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant