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

Function integration_setup

tests/test_integration.c:100–142  ·  view source on GitHub ↗

Set up: create project, index it through MCP (production flow) */

Source from the content-addressed store, hash-verified

98
99/* Set up: create project, index it through MCP (production flow) */
100static int integration_setup(void) {
101 if (create_test_project() != 0)
102 return -1;
103
104 /* Derive project name (same logic the pipeline uses) */
105 g_project = cbm_project_name_from_path(g_tmpdir);
106 if (!g_project)
107 return -1;
108
109 /* Build db path for direct store queries (pipeline writes here) */
110 const char *cache_dir = cbm_resolve_cache_dir();
111 int dbpath_length =
112 cache_dir ? snprintf(g_dbpath, sizeof(g_dbpath), "%s/%s.db", cache_dir, g_project) : -1;
113 if (dbpath_length <= 0 || (size_t)dbpath_length >= sizeof(g_dbpath) ||
114 !cbm_mkdir_p(cache_dir, 0700)) {
115 return -1;
116 }
117
118 /* Remove stale db from previous test runs */
119 unlink(g_dbpath);
120
121 /* Create MCP server, then index through it (production flow):
122 * 1. Server starts with in-memory store
123 * 2. index_repository closes in-memory store
124 * 3. Pipeline runs → dumps to ~/.cache/.../<project>.db
125 * 4. Server reopens from that db
126 * This exercises the exact same path as real usage. */
127 g_srv = cbm_mcp_server_new(NULL);
128 if (!g_srv)
129 return -1;
130
131 /* Index our temp project via MCP tool handler */
132 char args[512];
133 snprintf(args, sizeof(args), "{\"repo_path\":\"%s\"}", g_tmpdir);
134 char *resp = cbm_mcp_handle_tool(g_srv, "index_repository", args);
135 if (!resp)
136 return -1;
137
138 /* Verify indexing succeeded */
139 bool ok = strstr(resp, "indexed") != NULL;
140 free(resp);
141 return ok ? 0 : -1;
142}
143
144static void integration_teardown(void) {
145 if (g_srv) {

Callers 1

test_integration.cFile · 0.85

Calls 6

create_test_projectFunction · 0.85
cbm_resolve_cache_dirFunction · 0.85
cbm_mkdir_pFunction · 0.85
cbm_mcp_server_newFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85

Tested by

no test coverage detected