Ch1
This commit is contained in:
@@ -79,3 +79,35 @@ func TestArticleDraftContextCarriesArticleType(t *testing.T) {
|
||||
t.Fatalf("article type missing from draft context: %s", contextValue)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateArticleDraftUsesLowerConceptAnswerMinimum(t *testing.T) {
|
||||
e := &Engine{Cfg: config.Config{
|
||||
ArticleMinTextChars: 100,
|
||||
ArticleMinAnswerChars: 420,
|
||||
ArticleMinConfidence: .7,
|
||||
ArticleMinSources: 1,
|
||||
ArticleMinProductionRatio: 1,
|
||||
ArticleMaxGenerationDepth: 2,
|
||||
}}
|
||||
draft := model.KnowledgeArticleDraft{
|
||||
Title: "Mobile Authentifizierung einordnen",
|
||||
Text: strings.Repeat("Fachlich belegte Einordnung. ", 6),
|
||||
Answer: "## Kernaussagen\n- Authentifizierung bestätigt eine Identität anhand belegter Merkmale.\n- Biometrische Merkmale können die lokale Nutzerprüfung unterstützen.\n\n## Einordnung und Abgrenzung\n- Autorisierung entscheidet anschließend über erlaubte Aktionen und Ressourcen.",
|
||||
Confidence: .9,
|
||||
}
|
||||
sources := []articleSource{{Node: model.Node{Kind: "knowledge", Status: "production"}}}
|
||||
if err := e.validateArticleDraft(draft, "concept", sources, 1, 1); err != nil {
|
||||
t.Fatalf("grounded concept draft should pass type-aware validation: %v", err)
|
||||
}
|
||||
if err := e.validateArticleDraft(draft, "how_to", sources, 1, 1); err == nil {
|
||||
t.Fatal("the same short answer must not pass the operational how-to minimum")
|
||||
}
|
||||
}
|
||||
|
||||
func TestArticleDraftValidationMetadataIsStructured(t *testing.T) {
|
||||
err := newArticleDraftValidationError("answer_too_short", "answer", 311, 420, "too short")
|
||||
metadata := articleDraftValidationMetadata(err)
|
||||
if metadata["reason"] != "answer_too_short" || metadata["field"] != "answer" || metadata["actual"] != 311 || metadata["required"] != 420 {
|
||||
t.Fatalf("unexpected validation metadata: %#v", metadata)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user