| | | 1 | | #include "../../api/handlers/report_handler.h" |
| | | 2 | | #include "../../api/http_server.h" |
| | | 3 | | |
| | | 4 | | #include <assert.h> |
| | | 5 | | #include <string.h> |
| | | 6 | | #include <stdio.h> |
| | | 7 | | #include <stdlib.h> |
| | | 8 | | |
| | 1 | 9 | | void test_generate_maintenance_xml() { |
| | 1 | 10 | | char *xml = generate_maintenance_xml_report(); |
| | 1 | 11 | | assert(xml != NULL); |
| | 1 | 12 | | assert(strstr(xml, "Maintenance Report") != NULL); |
| | 1 | 13 | | free(xml); |
| | 1 | 14 | | printf("[PASS] generate_maintenance_xml_report\n"); |
| | 1 | 15 | | } |
| | | 16 | | |
| | 1 | 17 | | void test_generate_inventory_xml() { |
| | 1 | 18 | | char *xml = generate_inventory_xml_report(); |
| | 1 | 19 | | assert(xml != NULL); |
| | 1 | 20 | | assert(strstr(xml, "Inventory Report") != NULL); |
| | 1 | 21 | | free(xml); |
| | 1 | 22 | | printf("[PASS] generate_inventory_xml_report\n"); |
| | 1 | 23 | | } |
| | | 24 | | |
| | 1 | 25 | | void test_handle_report_maintenance() { |
| | 1 | 26 | | HttpRequest req = {0}; |
| | 1 | 27 | | HttpResponse res = {0}; |
| | 1 | 28 | | strcpy(req.path, "/api/report/maintenance"); |
| | 1 | 29 | | handle_report_request(&req, &res); |
| | 1 | 30 | | assert(res.status_code == 200); |
| | 1 | 31 | | assert(strcmp(res.content_type, "application/xml") == 0); |
| | 1 | 32 | | assert(strstr(res.body, "Maintenance Report") != NULL); |
| | 1 | 33 | | printf("[PASS] handle_report_request maintenance\n"); |
| | 1 | 34 | | } |
| | | 35 | | |
| | 1 | 36 | | void test_handle_report_inventory() { |
| | 1 | 37 | | HttpRequest req = {0}; |
| | 1 | 38 | | HttpResponse res = {0}; |
| | 1 | 39 | | strcpy(req.path, "/api/report/inventory"); |
| | 1 | 40 | | handle_report_request(&req, &res); |
| | 1 | 41 | | assert(res.status_code == 200); |
| | 1 | 42 | | assert(strcmp(res.content_type, "application/xml") == 0); |
| | 1 | 43 | | assert(strstr(res.body, "Inventory Report") != NULL); |
| | 1 | 44 | | printf("[PASS] handle_report_request inventory\n"); |
| | 1 | 45 | | } |
| | | 46 | | |
| | 1 | 47 | | int main() { |
| | 1 | 48 | | test_generate_maintenance_xml(); |
| | 1 | 49 | | test_generate_inventory_xml(); |
| | 1 | 50 | | test_handle_report_maintenance(); |
| | 1 | 51 | | test_handle_report_inventory(); |
| | 1 | 52 | | return 0; |
| | | 53 | | } |