Forge
csharp9332cf7c
1using HybridCodebaseIndex.Core;
2
3namespace HybridCodebaseIndex.Core.Tests;
4
5public sealed class CodebaseIndexIntegrationTests
6{
7 [Fact]
8 public async Task Reindex_then_search_find_hit()
9 {
10 var ws = Path.Combine(Path.GetTempPath(), "hca-index-test-" + Guid.NewGuid().ToString("n"));
11 Directory.CreateDirectory(ws);
12 try
13 {
14 await File.WriteAllTextAsync(Path.Combine(ws, "note.md"), """
15# Sample
16Hello hybrid codebase index FTS5 smoke.
17""");
18
19 var svc = new CodebaseIndexService(".test-hybrid-index");
20 await svc.FullReindexAsync(ws);
21
22 var (resp, err) = await svc.SearchAsync(ws, "hybrid FTS5", topN: 5);
23 Assert.Null(err);
24 Assert.Contains(resp.Hits, h => h.Path.Replace('\\', '/') == "note.md" && h.HitKind == HitKinds.TextFts);
25
26 var st = await svc.GetStatusAsync(ws);
27 Assert.True(st.DatabaseExists);
28 Assert.True(st.DocumentCount >= 1);
29 }
30 finally
31 {
32 TryDelete(ws);
33 }
34 }
35
36 private static void TryDelete(string path)
37 {
38 try
39 {
40 if (Directory.Exists(path))
41 Directory.Delete(path, recursive: true);
42 }
43 catch
44 {
45 // temp cleanup best-effort
46 }
47 }
48}
49
View only · write via MCP/CIDE