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

Function TestDetectOutdated

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

Source from the content-addressed store, hash-verified

127}
128
129func TestDetectOutdated(t *testing.T) {
130 config := DefaultQualityMetricsConfig()
131 qm := NewQualityMetrics(config)
132 qa := NewQualityAnalyzer(qm, nil)
133
134 // 创建旧记忆(200天前)
135 oldProvenance := NewProvenance(SourceUserInput, "user-1")
136 oldProvenance.CreatedAt = time.Now().Add(-200 * 24 * time.Hour)
137
138 // 创建新记忆(1天前)
139 newProvenance := NewProvenance(SourceUserInput, "user-2")
140 newProvenance.CreatedAt = time.Now().Add(-24 * time.Hour)
141
142 memories := []MemoryWithScore{
143 {
144 DocID: "old",
145 Text: "Old memory",
146 Provenance: oldProvenance,
147 },
148 {
149 DocID: "new",
150 Text: "New memory",
151 Provenance: newProvenance,
152 },
153 }
154
155 outdated := qa.detectOutdated(memories)
156
157 // 应该只检测到旧记忆
158 if len(outdated) != 1 {
159 t.Errorf("detected %d outdated memories, want 1", len(outdated))
160 }
161
162 if len(outdated) > 0 {
163 if outdated[0].Type != InconsistencyOutdated {
164 t.Errorf("type = %s, want %s", outdated[0].Type, InconsistencyOutdated)
165 }
166
167 if outdated[0].MemoryID1 != "old" {
168 t.Errorf("outdated MemoryID = %s, want old", outdated[0].MemoryID1)
169 }
170 }
171}
172
173func TestDetectLowConfidence(t *testing.T) {
174 config := DefaultQualityMetricsConfig()

Callers

nothing calls this directly

Calls 6

detectOutdatedMethod · 0.95
NewQualityMetricsFunction · 0.85
NewQualityAnalyzerFunction · 0.85
NewProvenanceFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected