MCPcopy Index your code
hub / github.com/docker/docker-agent / TestGetMemories

Function TestGetMemories

pkg/memory/database/sqlite/sqlite_test.go:95–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestGetMemories(t *testing.T) {
96 t.Parallel()
97 db := setupTestDB(t)
98
99 memories, err := db.GetMemories(t.Context())
100 require.NoError(t, err)
101 assert.Empty(t, memories, "Empty database should return empty memories slice")
102
103 testMemories := []database.UserMemory{
104 {
105 ID: "test-id-1",
106 CreatedAt: time.Now().Format(time.RFC3339),
107 Memory: "First test memory",
108 },
109 {
110 ID: "test-id-2",
111 CreatedAt: time.Now().Format(time.RFC3339),
112 Memory: "Second test memory",
113 },
114 }
115
116 for _, memory := range testMemories {
117 err := db.AddMemory(t.Context(), memory)
118 require.NoError(t, err)
119 }
120
121 memories, err = db.GetMemories(t.Context())
122 require.NoError(t, err)
123 assert.Len(t, memories, 2, "Should retrieve both added memories")
124
125 memoryMap := make(map[string]database.UserMemory)
126 for _, memory := range memories {
127 memoryMap[memory.ID] = memory
128 }
129
130 for _, expected := range testMemories {
131 actual, exists := memoryMap[expected.ID]
132 assert.True(t, exists, "Memory with ID %s should exist", expected.ID)
133 assert.Equal(t, expected.Memory, actual.Memory)
134 assert.Equal(t, expected.CreatedAt, actual.CreatedAt)
135 }
136}
137
138func TestDeleteMemory(t *testing.T) {
139 t.Parallel()

Callers

nothing calls this directly

Calls 6

setupTestDBFunction · 0.85
ContextMethod · 0.80
NowMethod · 0.80
GetMemoriesMethod · 0.65
AddMemoryMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected