MCPcopy Create free account
hub / github.com/diillson/chatcli / newContextTestCLI

Function newContextTestCLI

cli/context_adapter_test.go:20–39  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
20func 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
41func TestContextAdapter_EndToEnd(t *testing.T) {
42 cli, corpus := newContextTestCLI(t)

Callers 3

Calls 4

GetManagerMethod · 0.95
NewNullFunction · 0.92
NewContextHandlerFunction · 0.85

Tested by

no test coverage detected