diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2026-02-21 11:14:42 +0100 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2026-02-21 11:14:42 +0100 |
| commit | 1b19afaa339f2f68520d61b634600ddeb04effb7 (patch) | |
| tree | 232ec9fdc03a8955a8c847b88a688306689d2633 /test | |
| parent | 0b6e8026a6b530c7d88607bfdf79b9692987abaa (diff) | |
Split up the rendering from the logic
Diffstat (limited to 'test')
| -rw-r--r-- | test/http.c | 10 | ||||
| -rw-r--r-- | test/list_clients.c | 14 |
2 files changed, 11 insertions, 13 deletions
diff --git a/test/http.c b/test/http.c index 97f7a6b..0d18242 100644 --- a/test/http.c +++ b/test/http.c @@ -1,3 +1,4 @@ +#include "app.h" #include "web.h" #include "mytime.h" @@ -50,7 +51,7 @@ int main(int argc, char **argv) { struct App app = { .dbname = "file::memory:?cache=shared", }; - prepare_database(&app); + app_startup(&app); struct Server server = { .app = &app, }; @@ -320,16 +321,15 @@ int main(int argc, char **argv) { assert(code == 204); body = (struct memory){0}; - // Use internal function to verify backup statuses - struct Request req = { .server = &server }; + // Use app layer functions to verify backup statuses struct GetClientOnlyResult client_result; - int ret = get_client(&req, 1, &client_result); + int ret = get_client(&app, 1, &client_result); assert(ret == 0); assert(client_result.found == 1); struct GetBackupsResult *backups_result = malloc(sizeof(struct GetBackupsResult) + sizeof(struct BackupRecord) * MAX_BACKUPS_DISPLAY); backups_result->backups_len = MAX_BACKUPS_DISPLAY; - ret = get_client_backups(&req, 1, backups_result); + ret = get_client_backups(&app, 1, backups_result); assert(ret == 0); // Should have at least 2 backups (the interrupted one and the running one) diff --git a/test/list_clients.c b/test/list_clients.c index ea34794..3cab798 100644 --- a/test/list_clients.c +++ b/test/list_clients.c @@ -1,4 +1,4 @@ -#include "web.h" +#include "app.h" #include <assert.h> #include <stdio.h> @@ -7,21 +7,19 @@ int main() { struct App app = { .dbname = "file::memory:?cache=shared" }; - prepare_database(&app); - struct Server server = { .app = &app }; - struct Request request = { .server = &server }; + app_startup(&app); - // Insert 17 clients using create_client + // Insert 17 clients using app_create_client for (int i = 1; i <= 17; i++) { char name[32]; snprintf(name, sizeof(name), "client%d", i); struct CreateClientResult cr; - create_client(&request, name, &cr); + create_client(&app, name, &cr); } - // Call list_clients + // Call app_list_clients struct ListClientResult *result = malloc(sizeof(*result) + 16 * sizeof(struct ListClientResultClient)); - list_clients(&request, result); + list_clients(&app, result); // Verify: exactly 16 returned, correct order and names assert(result->clients_len == 16); |
