newContextTestCLI builds a minimal ChatCLI whose context manager lives under a throwaway HOME, plus a docs-flatten JSONL corpus on disk to build from.
(t *testing.T)
| 18 | // newContextTestCLI builds a minimal ChatCLI whose context manager lives under |
| 19 | // a throwaway HOME, plus a docs-flatten JSONL corpus on disk to build from. |
| 20 | func newContextTestCLI(t *testing.T) (*ChatCLI, string) { |
| 21 | t.Helper() |
| 22 | t.Setenv("HOME", t.TempDir()) |
| 23 | |
| 24 | handler, err := NewContextHandler(zap.NewNop()) |
| 25 | if err != nil { |
| 26 | t.Fatalf("NewContextHandler: %v", err) |
| 27 | } |
| 28 | handler.GetManager().AttachEmbeddingProvider(embedding.NewNull()) |
| 29 | |
| 30 | corpus := filepath.Join(t.TempDir(), "docs.jsonl") |
| 31 | lines := strings.Join([]string{ |
| 32 | `{"id":"guide/install.md#0001","source":"guide/install.md","content":"# Install\nHow to install the CLI."}`, |
| 33 | `{"id":"api/auth.md#0001","source":"api/auth.md","content":"# Auth\noauth login bearer token flows"}`, |
| 34 | }, "\n") |
| 35 | if err := os.WriteFile(corpus, []byte(lines), 0o600); err != nil { |
| 36 | t.Fatal(err) |
| 37 | } |
| 38 | return &ChatCLI{contextHandler: handler, logger: zap.NewNop()}, corpus |
| 39 | } |
| 40 | |
| 41 | func TestContextAdapter_EndToEnd(t *testing.T) { |
| 42 | cli, corpus := newContextTestCLI(t) |
no test coverage detected