MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / test_count_hook_command

Function test_count_hook_command

tests/test_cli.c:602–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600}
601
602static size_t test_count_hook_command(yyjson_val *root, const char *event_name,
603 const char *expected_command) {
604 yyjson_val *hooks = root ? yyjson_obj_get(root, "hooks") : NULL;
605 yyjson_val *entries = hooks && yyjson_is_obj(hooks) ? yyjson_obj_get(hooks, event_name) : NULL;
606 if (!entries || !yyjson_is_arr(entries)) {
607 return 0U;
608 }
609 size_t count = 0U;
610 size_t entry_index;
611 size_t entry_count;
612 yyjson_val *entry;
613 yyjson_arr_foreach(entries, entry_index, entry_count, entry) {
614 yyjson_val *entry_hooks = yyjson_is_obj(entry) ? yyjson_obj_get(entry, "hooks") : NULL;
615 if (!entry_hooks || !yyjson_is_arr(entry_hooks)) {
616 continue;
617 }
618 size_t hook_index;
619 size_t hook_count;
620 yyjson_val *hook;
621 yyjson_arr_foreach(entry_hooks, hook_index, hook_count, hook) {
622 yyjson_val *command = yyjson_is_obj(hook) ? yyjson_obj_get(hook, "command") : NULL;
623 if (command && yyjson_is_str(command) &&
624 strcmp(yyjson_get_str(command), expected_command) == 0) {
625 count++;
626 }
627 }
628 }
629 return count;
630}
631#endif
632
633static char *save_test_env(const char *name) {

Callers 1

test_cli.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected