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. */
| 8099 | * name is `internal` (which may differ from the filename), holding one |
| 8100 | * Function node named `fn`. Returns true on success. */ |
| 8101 | static bool issue704_make_db(const char *dir, const char *filename, const char *internal, |
| 8102 | const char *fn) { |
| 8103 | char path[700]; |
| 8104 | snprintf(path, sizeof(path), "%s/%s", dir, filename); |
| 8105 | cbm_store_t *st = cbm_store_open_path(path); |
| 8106 | if (!st) { |
| 8107 | return false; |
| 8108 | } |
| 8109 | bool ok = (cbm_store_upsert_project(st, internal, dir) == CBM_STORE_OK); |
| 8110 | if (ok) { |
| 8111 | char qn[256]; |
| 8112 | snprintf(qn, sizeof(qn), "%s.%s", internal, fn); |
| 8113 | cbm_node_t n = {0}; |
| 8114 | n.project = internal; |
| 8115 | n.label = "Function"; |
| 8116 | n.name = fn; |
| 8117 | n.qualified_name = qn; |
| 8118 | n.file_path = "main.go"; |
| 8119 | n.start_line = 1; |
| 8120 | n.end_line = 2; |
| 8121 | ok = (cbm_store_upsert_node(st, &n) > 0); |
| 8122 | } |
| 8123 | cbm_store_close(st); |
| 8124 | return ok; |
| 8125 | } |
| 8126 | |
| 8127 | TEST(tool_resolve_store_by_internal_name_issue704) { |
| 8128 | char cache[256]; |
no test coverage detected