feat: add ontology material ingestion
This commit is contained in:
53
internal/ontology/service_test.go
Normal file
53
internal/ontology/service_test.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package ontology
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIngestCreatesSourceBackedCandidates(t *testing.T) {
|
||||
service := NewService(NewMemoryStore())
|
||||
|
||||
result, err := service.Ingest(IngestInput{
|
||||
Title: "Backend interview notes",
|
||||
SourceType: "markdown",
|
||||
Body: "Idempotent API retries need transactions. Cache invalidation uses TTL tradeoffs.",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Ingest error: %v", err)
|
||||
}
|
||||
if result.Material.ID == "" {
|
||||
t.Fatal("expected material id")
|
||||
}
|
||||
if len(result.Snapshot.Concepts) == 0 {
|
||||
t.Fatal("expected concept candidates")
|
||||
}
|
||||
for _, concept := range result.Snapshot.Concepts {
|
||||
if concept.ReviewState != ReviewCandidate {
|
||||
t.Fatalf("review state = %q", concept.ReviewState)
|
||||
}
|
||||
if len(concept.Evidence) == 0 {
|
||||
t.Fatal("expected concept evidence")
|
||||
}
|
||||
}
|
||||
if len(result.Snapshot.Edges) == 0 {
|
||||
t.Fatal("expected prerequisite edge candidates")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIngestMarksGapsAsCandidates(t *testing.T) {
|
||||
service := NewService(NewMemoryStore())
|
||||
|
||||
result, err := service.Ingest(IngestInput{
|
||||
Title: "Cache note",
|
||||
Body: "Cache invalidation is hard.",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Ingest error: %v", err)
|
||||
}
|
||||
if len(result.Snapshot.Gaps) == 0 {
|
||||
t.Fatal("expected gaps")
|
||||
}
|
||||
for _, gap := range result.Snapshot.Gaps {
|
||||
if gap.ReviewState != ReviewCandidate {
|
||||
t.Fatalf("gap review state = %q", gap.ReviewState)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user