Skip to content

test(app): smoke tests for named routes, healthz, and set_error_handler (#342) - #388

Open
Bhumika-1432006 wants to merge 1 commit into
c4punks:devfrom
Bhumika-1432006:test/342-app-routing-error-handler
Open

Bhumika-1432006 wants to merge 1 commit into
c4punks:devfrom
Bhumika-1432006:test/342-app-routing-error-handler

Conversation

@Bhumika-1432006

Copy link
Copy Markdown
Contributor

Four cwist_app_* functions from issue #342's uncovered list have no test: cwist_app_post_named, cwist_app_delete_named, cwist_app_enable_healthz, and cwist_app_set_error_handler.

What this adds: tests/test_app_named_routes_and_error_handler.c with one case per function:

  • post_named: register a POST route with a name, verify cwist_url_for returns the registered path.
  • delete_named: same for DELETE; confirms paths with :param segments are stored.
  • enable_healthz: call it and confirm no crash; check cwist_url_for for the /healthz path when a name is registered.
  • set_error_handler: verify app->error_handler is NULL before the call, set to the supplied function pointer after, and NULL-cleared on a second call with NULL. Confirm NULL app is a safe no-op.

How it was verified: no live server is started; the tests only exercise the registration and lookup paths. The assertions follow directly from the function signatures and the app struct layout in app.h. The test is wired into make test via a new Makefile target.

What it does not do: does not cover cwist_app_multiport, cwist_app_set_tls_groups, cwist_app_ws_opt, or the other uncovered functions listed in issue #342.

…er (c4punks#342)

Four cwist_app_* functions from issue c4punks#342's uncovered list have no test:
cwist_app_post_named, cwist_app_delete_named, cwist_app_enable_healthz, and
cwist_app_set_error_handler.

This adds tests/test_app_named_routes_and_error_handler.c with one case per
function:

- post_named: register a POST route with a name and verify cwist_url_for
  returns the registered path.
- delete_named: same for DELETE; confirms :param paths are stored.
- enable_healthz: call it and confirm no crash; check cwist_url_for for the
  /healthz path when a name is registered.
- set_error_handler: verify app->error_handler is NULL before the call, set
  to the supplied function pointer after, and NULL-cleared on a second call
  with NULL. Confirm NULL app is a safe no-op.

No live server is started; the tests only exercise registration and lookup.
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