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

Function TestBuildMemorySection

pkg/middleware/logic_memory_test.go:466–529  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

464}
465
466func TestBuildMemorySection(t *testing.T) {
467 store := logic.NewInMemoryStore()
468 manager, err := logic.NewManager(&logic.ManagerConfig{Store: store})
469 require.NoError(t, err)
470
471 mw, err := NewLogicMemoryMiddleware(&LogicMemoryMiddlewareConfig{
472 Manager: manager,
473 })
474 require.NoError(t, err)
475
476 t.Run("build with memories", func(t *testing.T) {
477 memories := []*logic.LogicMemory{
478 {
479 Type: "preference",
480 Key: "tone",
481 Description: "用户偏好口语化表达",
482 Provenance: &memory.MemoryProvenance{
483 Confidence: 0.85,
484 },
485 },
486 {
487 Type: "behavior",
488 Key: "format",
489 Description: "用户喜欢使用列表格式",
490 Category: "formatting",
491 Provenance: &memory.MemoryProvenance{
492 Confidence: 0.7,
493 },
494 },
495 }
496
497 section := mw.buildMemorySection(memories)
498
499 assert.Contains(t, section, "User Preferences")
500 assert.Contains(t, section, "preference")
501 assert.Contains(t, section, "tone")
502 assert.Contains(t, section, "口语化")
503 assert.Contains(t, section, "85%")
504 assert.Contains(t, section, "behavior")
505 assert.Contains(t, section, "format")
506 assert.Contains(t, section, "列表格式")
507 assert.Contains(t, section, "70%")
508 assert.Contains(t, section, "formatting")
509 })
510
511 t.Run("empty memories", func(t *testing.T) {
512 section := mw.buildMemorySection([]*logic.LogicMemory{})
513 assert.Empty(t, section)
514 })
515
516 t.Run("nil provenance", func(t *testing.T) {
517 memories := []*logic.LogicMemory{
518 {
519 Type: "preference",
520 Key: "test",
521 Description: "Test memory",
522 Provenance: nil,
523 },

Callers

nothing calls this directly

Calls 5

buildMemorySectionMethod · 0.95
NewInMemoryStoreFunction · 0.92
NewManagerFunction · 0.92
NewLogicMemoryMiddlewareFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected