Create a file-backed project db at / whose INTERNAL project * name is `internal` (which may differ from the filename), holding one * Function node named `fn`. Returns true on success. */
| 8321 | * name is `internal` (which may differ from the filename), holding one |
| 8322 | * Function node named `fn`. Returns true on success. */ |
| 8323 | static bool issue704_make_db(const char *dir, const char *filename, const char *internal, |
| 8324 | const char *fn) { |
| 8325 | char path[700]; |
| 8326 | snprintf(path, sizeof(path), "%s/%s", dir, filename); |
| 8327 | cbm_store_t *st = cbm_store_open_path(path); |
| 8328 | if (!st) { |
| 8329 | return false; |
| 8330 | } |
| 8331 | bool ok = (cbm_store_upsert_project(st, internal, dir) == CBM_STORE_OK); |
| 8332 | if (ok) { |
| 8333 | char qn[256]; |
| 8334 | snprintf(qn, sizeof(qn), "%s.%s", internal, fn); |
| 8335 | cbm_node_t n = {0}; |
| 8336 | n.project = internal; |
| 8337 | n.label = "Function"; |
| 8338 | n.name = fn; |
| 8339 | n.qualified_name = qn; |
| 8340 | n.file_path = "main.go"; |
| 8341 | n.start_line = 1; |
| 8342 | n.end_line = 2; |
| 8343 | ok = (cbm_store_upsert_node(st, &n) > 0); |
| 8344 | } |
| 8345 | cbm_store_close(st); |
| 8346 | return ok; |
| 8347 | } |
| 8348 | |
| 8349 | TEST(tool_resolve_store_by_internal_name_issue704) { |
| 8350 | char cache[256]; |
no test coverage detected