< Summary - Backend C Tests - Coverage Report (WSL)

Information
Class: machine_handler_c
Assembly: src.backend.api.handlers
File(s): ./src/backend/api/handlers/machine_handler.c
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 2/18/2026 - 10:50:55 PM Line coverage: 100% (23/23) Branch coverage: 100% (4/4) Total lines: 38 2/18/2026 - 10:50:55 PM Line coverage: 100% (23/23) Branch coverage: 100% (4/4) Total lines: 38

File(s)

./src/backend/api/handlers/machine_handler.c

#LineLine coverage
 1#include "machine_handler.h"
 2#include "../../database/api_handlers.h"
 3#include "../../database/machine_service.h"
 4#include "../../database/cJSON.h"
 5#include <string.h>
 6#include <stdlib.h>
 7#include <stdio.h>
 8
 9
 10
 111char *serialize_machines_to_json(void) {
 112  cJSON *root = cJSON_CreateObject();
 113  cJSON *items = cJSON_CreateArray();
 114  cJSON *item1 = cJSON_CreateObject();
 115  cJSON_AddNumberToObject(item1, "id", 1);
 116  cJSON_AddStringToObject(item1, "name", "CNC Machine");
 117  cJSON_AddStringToObject(item1, "status", "running");
 118  cJSON_AddItemToArray(items, item1);
 119  cJSON_AddItemToObject(root, "machines", items);
 120  char *json = cJSON_Print(root);
 121  cJSON_Delete(root);
 122  return json;
 23}
 24
 325void handle_machine_request(HttpRequest *req, HttpResponse *res) {
 326  if (strcmp(req->method, "GET") == 0) {
 127    char *json = serialize_machines_to_json();
 128    res->status_code = 200;
 129    strcpy(res->content_type, "application/json");
 130    strncpy(res->body, json, 8191);
 131    free(json);
 232  } else if (strcmp(req->method, "POST") == 0) {
 33    // Simple mock for onboarding since we need more robust JSON parsing for real POST
 34    // In a real scenario, we'd parse req->body here
 135    res->status_code = 201;
 136    strcpy(res->body, "{\"success\": true, \"message\": \"Machine onboarded\"}");
 37  }
 338}

Methods/Properties