1 Test Gaps
Claude edited this page 2026-02-19 23:35:15 +00:00

Test Gaps

Detailed test suggestions per file. Phase 1 tests (no external services) are highest priority.

Phase 1: Pure Function Tests

query.go — FormatResults* (3 tests)

func TestFormatResultsText(t *testing.T) {
    results := []QueryResult{{Content: "hello", Source: "doc.md", Score: 0.95}}
    out := FormatResultsText(results)
    assert.Contains(t, out, "hello")
    assert.Contains(t, out, "doc.md")
}

func TestFormatResultsContext(t *testing.T) { /* XML wrapping */ }
func TestFormatResultsJSON(t *testing.T)    { /* JSON encoding */ }

ollama.go — EmbedDimension (4 tests)

func TestEmbedDimension(t *testing.T) {
    tests := []struct{ model string; want int }{
        {"nomic-embed-text", 768},
        {"mxbai-embed-large", 1024},
        {"all-minilm", 384},
        {"unknown-model", 768}, // default
    }
    for _, tt := range tests {
        t.Run(tt.model, func(t *testing.T) {
            c := &OllamaClient{Model: tt.model}
            assert.Equal(t, tt.want, c.EmbedDimension())
        })
    }
}

qdrant.go — valueToGo (7 tests)

Qdrant returns *pb.Value union types. valueToGo converts them to Go native types.

func TestValueToGo(t *testing.T) {
    tests := []struct {
        name string
        val  *pb.Value
        want any
    }{
        {"string", stringVal("hello"), "hello"},
        {"int", intVal(42), int64(42)},
        {"double", doubleVal(3.14), 3.14},
        {"bool", boolVal(true), true},
        {"nil", nil, nil},
        // Also: list, struct
    }
}

Default configs (5 tests)

Verify DefaultQdrantConfig, DefaultOllamaConfig, DefaultQueryConfig, DefaultChunkConfig, DefaultIngestConfig return expected field values.

chunk.go — Additional edge cases (4 tests)

func TestChunkEmpty(t *testing.T)         { /* empty string → no chunks */ }
func TestChunkOnlyHeaders(t *testing.T)   { /* ## A \n ## B → no content chunks */ }
func TestChunkUnicode(t *testing.T)       { /* emoji, CJK, RTL */ }
func TestChunkVeryLong(t *testing.T)      { /* single 50KB paragraph */ }

Phase 2: Mock-Based Tests (after interface extraction)

Embedder interface

type Embedder interface {
    Embed(ctx context.Context, text string) ([]float32, error)
    EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
    EmbedDimension() int
}

VectorStore interface

type VectorStore interface {
    CreateCollection(ctx context.Context, name string, size int) error
    Upsert(ctx context.Context, collection string, points []Point) error
    Search(ctx context.Context, collection string, vector []float32, limit int) ([]SearchResult, error)
    CollectionExists(ctx context.Context, name string) (bool, error)
    DeleteCollection(ctx context.Context, name string) error
}

Mock implementations enable:

  • ingest_test.go: Mock embedder returns deterministic vectors, mock store captures upserts — verify chunking → embedding → storage pipeline
  • query_test.go: Mock store returns known results, mock embedder returns known vector — verify search → format pipeline

Phase 3+: Integration Tests (build tag //go:build rag)

Require live Qdrant + Ollama. Create collection, ingest test document, query it, verify results, clean up.