a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package indexer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/zzet/gortex/internal/graph"
|
|
)
|
|
|
|
// TestPersistFileMeta_PopulatesFilesSidecar pins the end-to-end population of
|
|
// the per-file metadata sidecar: indexing a file records a row with a non-empty
|
|
// content hash, a positive byte size, and the extracted node count — the data
|
|
// index_health reports per file.
|
|
func TestPersistFileMeta_PopulatesFilesSidecar(t *testing.T) {
|
|
src := `package main
|
|
|
|
func Alpha() {}
|
|
|
|
func Beta() {}
|
|
`
|
|
g := indexAll(t, src) // single-repo mode → repoPrefix ""
|
|
|
|
reader, ok := g.(graph.FileMetaReader)
|
|
if !ok {
|
|
t.Fatal("in-memory graph must implement FileMetaReader")
|
|
}
|
|
rows, err := reader.FileMetasForRepo("")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(rows) == 0 {
|
|
t.Fatal("no file metadata rows recorded after indexing")
|
|
}
|
|
var found bool
|
|
for _, r := range rows {
|
|
if r.FilePath != "main.go" {
|
|
continue
|
|
}
|
|
found = true
|
|
if r.ContentHash == "" {
|
|
t.Error("content_hash empty")
|
|
}
|
|
if r.Size == 0 {
|
|
t.Errorf("size = 0, want > 0")
|
|
}
|
|
if r.NodeCount == 0 {
|
|
t.Errorf("node_count = 0, want > 0 (file node + 2 functions)")
|
|
}
|
|
if r.Errors != "" {
|
|
t.Errorf("clean file recorded errors: %q", r.Errors)
|
|
}
|
|
}
|
|
if !found {
|
|
t.Errorf("no row for main.go; rows = %+v", rows)
|
|
}
|
|
}
|