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

Function compare_write_fixture_store

tests/test_mcp.c:18584–18667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18582}
18583
18584static bool compare_write_fixture_store(const char *path, const char *project, bool target) {
18585 static const compare_node_spec_t base_nodes[] = {
18586 {"pkg.common", "Function", "src/common.c"}, {"pkg.base", "Function", "src/base.c"},
18587 {"pkg.changed", "Function", "src/old.c"}, {"pkg.source", "Module", "src/source.c"},
18588 {"pkg.sink", "Module", "src/sink.c"},
18589 };
18590 static const compare_node_spec_t target_nodes[] = {
18591 {"pkg.common", "Function", "src/common.c"}, {"pkg.target", "Function", "src/target.c"},
18592 {"pkg.changed", "Method", "src/new.c"}, {"pkg.source", "Module", "src/source.c"},
18593 {"pkg.sink", "Module", "src/sink.c"},
18594 };
18595 static const int base_order[] = {3, 2, 0, 4, 1};
18596 static const int target_order[] = {1, 4, 0, 2, 3};
18597 const compare_node_spec_t *nodes = target ? target_nodes : base_nodes;
18598 const int *order = target ? target_order : base_order;
18599
18600 cbm_store_t *store = cbm_store_open_path(path);
18601 if (!store ||
18602 cbm_store_upsert_project(store, project, "/tmp/compare-graphs-525") != CBM_STORE_OK) {
18603 cbm_store_close(store);
18604 return false;
18605 }
18606 int64_t ids[5] = {0};
18607 bool ok = true;
18608 for (size_t position = 0; position < 5; position++) {
18609 int index = order[position];
18610 cbm_node_t node = {
18611 .project = project,
18612 .label = nodes[index].label,
18613 .name = nodes[index].qualified_name,
18614 .qualified_name = nodes[index].qualified_name,
18615 .file_path = nodes[index].file_path,
18616 .properties_json = "{}",
18617 };
18618 ids[index] = cbm_store_upsert_node(store, &node);
18619 ok = ok && ids[index] > 0;
18620 }
18621
18622 cbm_edge_t common_call = {
18623 .project = project,
18624 .source_id = ids[3],
18625 .target_id = ids[4],
18626 .type = "CALLS",
18627 .properties_json = "{}",
18628 };
18629 cbm_edge_t common_import = {
18630 .project = project,
18631 .source_id = ids[3],
18632 .target_id = ids[4],
18633 .type = "IMPORTS",
18634 .properties_json = "{\"local_name\":\"Alpha\"}",
18635 };
18636 cbm_edge_t changed_import = {
18637 .project = project,
18638 .source_id = ids[3],
18639 .target_id = ids[4],
18640 .type = "IMPORTS",
18641 .properties_json = target ? "{\"local_name\":\"Gamma\"}" : "{\"local_name\":\"Beta\"}",

Callers 1

Calls 7

cbm_store_open_pathFunction · 0.85
cbm_store_upsert_projectFunction · 0.85
cbm_store_closeFunction · 0.85
cbm_store_upsert_nodeFunction · 0.85
cbm_store_insert_edgeFunction · 0.85
compare_write_coverageFunction · 0.85

Tested by

no test coverage detected