addrkit: deterministic address resolution service (Go)
- domain: address normalization/parsing, matching with explicit statuses - adapters: SQLite registry store, ArcGIS outages client, optional LLM rewriter, HTTP API - seed pipeline with duplicate handling and unparsed reporting - CLI (seed/verify/resolve), systemd unit, OpenAPI contract, tests
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package seed
|
||||
|
||||
import (
|
||||
"math"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestRealRegistryParseRate validates the parser against a real registry dump.
|
||||
// It is skipped unless ADDRKIT_REGISTRY points at one, so it never runs in a
|
||||
// plain `go test ./...` (no large fixture in the repo).
|
||||
//
|
||||
// Run it explicitly:
|
||||
//
|
||||
// ADDRKIT_REGISTRY=/path/to/address_registry.ndjson \
|
||||
// go test ./internal/seed -run TestRealRegistryParseRate -v
|
||||
func TestRealRegistryParseRate(t *testing.T) {
|
||||
path := os.Getenv("ADDRKIT_REGISTRY")
|
||||
if path == "" {
|
||||
t.Skip("ADDRKIT_REGISTRY not set")
|
||||
}
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
t.Fatalf("open registry: %v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
sources, err := ReadBulkNDJSON(f)
|
||||
if err != nil {
|
||||
t.Fatalf("read registry: %v", err)
|
||||
}
|
||||
entries, stats := Build(sources)
|
||||
|
||||
rate := 0.0
|
||||
if stats.Total > 0 {
|
||||
rate = float64(stats.Parsed) / float64(stats.Total) * 100
|
||||
}
|
||||
t.Logf("total=%d parsed=%d unparsed=%d distinct_streets=%d parse_rate=%.2f%%",
|
||||
stats.Total, stats.Parsed, stats.Unparsed, stats.DistinctStreets, rate)
|
||||
if len(stats.UnparsedSample) > 0 {
|
||||
t.Logf("unparsed sample: %v", stats.UnparsedSample)
|
||||
}
|
||||
|
||||
// A well-formed registry should parse almost perfectly. If this drops we
|
||||
// want a loud failure, not a silently degraded index.
|
||||
if stats.Total > 0 && rate < 98.0 {
|
||||
t.Errorf("parse rate %.2f%% below 98%%", math.Round(rate*100)/100)
|
||||
}
|
||||
if len(entries) == 0 {
|
||||
t.Error("no entries produced")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user