< Summary - Backend C Tests - Coverage Report

Information
Class: test_inventory_handler_c
Assembly: src.backend.tests.unit
File(s): C:\Users\yagiz\Desktop\Project\smart-maintenance-suite\src\backend\tests\unit\test_inventory_handler.c
Line coverage
97%
Covered lines: 35
Uncovered lines: 1
Coverable lines: 36
Total lines: 49
Line coverage: 97.2%
Branch coverage
50%
Covered branches: 7
Total branches: 14
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
test_inventory_get50%0090.91%
test_inventory_post_success50%00100%
test_inventory_invalid_method50%00100%
main100%00100%

File(s)

C:\Users\yagiz\Desktop\Project\smart-maintenance-suite\src\backend\tests\unit\test_inventory_handler.c

#LineLine coverage
 1#include "../../api/handlers/inventory_handler.h"
 2#include "../../api/http_server.h"
 3#include <assert.h>
 4#include <string.h>
 5#include <stdio.h>
 6
 17void test_inventory_get() {
 18  HttpRequest req = {0};
 19  HttpResponse res = {0};
 110  strcpy(req.method, "GET");
 111  handle_inventory_request(&req, &res);
 112  assert(res.status_code == 200);
 13
 114  if (strstr(res.body, "part_name") == NULL) {
 015    printf("[DEBUG] Inventory GET Failed. Body: %s\n", res.body);
 16  }
 17
 118  assert(strstr(res.body, "part_name") != NULL);
 119  printf("[PASS] Inventory GET\n");
 120}
 21
 122void test_inventory_post_success() {
 123  HttpRequest req = {0};
 124  HttpResponse res = {0};
 125  strcpy(req.method, "POST");
 126  strcpy(req.body, "{\"part_name\": \"Bearing\", \"sku\": \"BRG-001\", \"quantity\": 10, \"min_stock\": 5, \"cost\": 15.
 127  handle_inventory_request(&req, &res);
 128  assert(res.status_code == 201);
 129  assert(strstr(res.body, "success") != NULL);
 130  printf("[PASS] Inventory POST Success\n");
 131}
 32
 133void test_inventory_invalid_method() {
 134  HttpRequest req = {0};
 135  HttpResponse res = {0};
 136  strcpy(req.method, "DELETE"); // POST artık desteklendiği için DELETE kullanıyoruz
 137  handle_inventory_request(&req, &res);
 138  assert(res.status_code == 405);
 139  assert(strstr(res.body, "Method not supported") != NULL);
 140  printf("[PASS] Inventory 405\n");
 141}
 42
 143int main() {
 144  test_inventory_get();
 145  test_inventory_post_success();
 146  test_inventory_invalid_method();
 147  printf("\n✅ [PASS] Inventory handler test suite completed\n");
 148  return 0;
 49}