|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
#include <stdlib.h>

Go to the source code of this file.
Functions | |
Context Test Helpers | |
Helpers to create and manipulate opaque csilk_ctx_t objects in unit tests. | |
| csilk_ctx_t * | csilk_test_ctx_new (void) |
| Create a new mock context for testing (heap-allocated). | |
| void | csilk_test_ctx_free (csilk_ctx_t *c) |
| Free a mock context created via csilk_test_ctx_new(). | |
| void | csilk_test_ctx_set_handlers (csilk_ctx_t *c, csilk_handler_t *handlers) |
| Set the handler chain for a test context. | |
| void | csilk_test_ctx_set_request (csilk_ctx_t *c, const char *method, const char *path) |
| Manually set the request method and path for testing. | |
| void | csilk_test_ctx_set_handler_metadata (csilk_ctx_t *c, const char *perm_required, const char *perm_resource) |
| Manually set metadata for the current handler (mocking matched route). | |
| void | csilk_test_ctx_set_body (csilk_ctx_t *c, const char *body, size_t len) |
| Manually set the request body for testing. | |
| void | csilk_test_ctx_add_param (csilk_ctx_t *c, const char *key, const char *value) |
| Manually add a path parameter for testing. | |
| int | csilk_test_ctx_count_response_headers (csilk_ctx_t *c, const char *key, const char *value_contains) |
| Count response headers with a given key and optional value substring. | |
| void csilk_test_ctx_add_param | ( | csilk_ctx_t * | c, |
| const char * | key, | ||
| const char * | value | ||
| ) |
Manually add a path parameter for testing.
| c | The request context. |
| key | Parameter name. Copied. |
| value | Parameter value. Copied. |
| int csilk_test_ctx_count_response_headers | ( | csilk_ctx_t * | c, |
| const char * | key, | ||
| const char * | value_contains | ||
| ) |
Count response headers with a given key and optional value substring.
| c | The request context. |
| key | Header key to look up. |
| value_contains | Optional substring to match in the value. |
| void csilk_test_ctx_free | ( | csilk_ctx_t * | c | ) |
Free a mock context created via csilk_test_ctx_new().
| c | The context to free. |
| csilk_ctx_t * csilk_test_ctx_new | ( | void | ) |
Create a new mock context for testing (heap-allocated).
| void csilk_test_ctx_set_body | ( | csilk_ctx_t * | c, |
| const char * | body, | ||
| size_t | len | ||
| ) |
Manually set the request body for testing.
| c | The request context. |
| body | The raw request body string. Not copied. |
| len | Length of the body. |
| void csilk_test_ctx_set_handler_metadata | ( | csilk_ctx_t * | c, |
| const char * | perm_required, | ||
| const char * | perm_resource | ||
| ) |
Manually set metadata for the current handler (mocking matched route).
| c | The request context. |
| perm_required | Permission string. Not copied. |
| perm_resource | Resource pattern. Not copied. |
| void csilk_test_ctx_set_handlers | ( | csilk_ctx_t * | c, |
| csilk_handler_t * | handlers | ||
| ) |
Set the handler chain for a test context.
| c | The request context. |
| handlers | NULL-terminated array of handler functions. |
| void csilk_test_ctx_set_request | ( | csilk_ctx_t * | c, |
| const char * | method, | ||
| const char * | path | ||
| ) |
Manually set the request method and path for testing.
| c | The request context. |
| method | HTTP method string (e.g. "GET"). Not copied. |
| path | Decoded URL path string. Not copied. |