MCPcopy Create free account
hub / github.com/astercloud/aster / TestGenerateReport

Function TestGenerateReport

pkg/memory/quality_analyzer_test.go:332–377  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

330}
331
332func TestGenerateReport(t *testing.T) {
333 config := DefaultQualityMetricsConfig()
334 qm := NewQualityMetrics(config)
335 qa := NewQualityAnalyzer(qm, nil)
336
337 // 评估一些记忆
338 memories := []MemoryWithScore{}
339 for i := range 5 {
340 prov := NewProvenance(SourceUserInput, "user-1")
341 prov.Confidence = float64(i+1) * 0.15
342
343 mem := &MemoryWithScore{
344 DocID: string(rune('A' + i)),
345 Text: "Test memory content with varying quality scores",
346 Provenance: prov,
347 Score: float64(i+1) * 0.15,
348 }
349
350 _, _ = qm.Evaluate(context.Background(), string(rune('A'+i)), mem)
351 memories = append(memories, *mem)
352 }
353
354 // 生成报告
355 report, err := qa.GenerateReport(context.Background(), memories)
356 if err != nil {
357 t.Fatalf("GenerateReport failed: %v", err)
358 }
359
360 if report == nil {
361 t.Fatal("report should not be nil")
362 }
363
364 // 验证报告内容
365 if report.Stats.TotalMemories != 5 {
366 t.Errorf("TotalMemories = %d, want 5", report.Stats.TotalMemories)
367 }
368
369 if len(report.DimensionScores) == 0 {
370 t.Error("DimensionScores should not be empty")
371 }
372
373 // 验证建议不为空
374 if len(report.Recommendations) == 0 {
375 t.Error("Recommendations should not be empty for varying quality scores")
376 }
377}
378
379func TestGenerateRecommendations(t *testing.T) {
380 config := DefaultQualityMetricsConfig()

Callers

nothing calls this directly

Calls 7

EvaluateMethod · 0.95
GenerateReportMethod · 0.95
NewQualityMetricsFunction · 0.85
NewQualityAnalyzerFunction · 0.85
NewProvenanceFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected