Files
glpi-neural-brain/internal/ingest/knowledge_test.go
T
2026-08-04 03:43:12 +02:00

46 lines
1.4 KiB
Go

package ingest
import (
"os"
"path/filepath"
"testing"
"github.com/local/glpi-neural-brain/internal/graph"
)
func TestKnowledgeScannerIncludesAIThinkStaging(t *testing.T) {
root := t.TempDir()
prod := filepath.Join(root, "knowledge")
stage := filepath.Join(root, "staging")
if err := os.MkdirAll(prod, 0755); err != nil {
t.Fatal(err)
}
if err := os.MkdirAll(stage, 0755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(prod, "vpn.json"), []byte(`{"id":"KB-VPN","title":"VPN","text":"Gateway","categories":["Netzwerk"],"keywords":["VPN"],"source":"internal-kb"}`), 0644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(stage, "think.json"), []byte(`{"id":"KB-AI-1","title":"VPN Zusammenhang","text":"Synthese","categories":["AI-THINK"],"keywords":["VPN"],"source":"Neural Brain"}`), 0644); err != nil {
t.Fatal(err)
}
g, _ := graph.Open(filepath.Join(root, "data"))
s := KnowledgeScanner{Graph: g, ProductionDirs: []string{prod}, StagingDirs: []string{stage}}
if _, err := s.Scan(); err != nil {
t.Fatal(err)
}
snap := g.Snapshot()
var prodOK, thinkOK bool
for _, n := range snap.Nodes {
if n.ExternalID == "KB-VPN" && n.Status == "production" {
prodOK = true
}
if n.ExternalID == "KB-AI-1" && n.Kind == "ai-think" && n.Status == "staging" {
thinkOK = true
}
}
if !prodOK || !thinkOK {
t.Fatalf("missing nodes: prod=%v think=%v", prodOK, thinkOK)
}
}