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

Function TestDeleteMemory

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

Source from the content-addressed store, hash-verified

136}
137
138func TestDeleteMemory(t *testing.T) {
139 t.Parallel()
140 db := setupTestDB(t)
141
142 memory := database.UserMemory{
143 ID: "test-id-1",
144 CreatedAt: time.Now().Format(time.RFC3339),
145 Memory: "Test memory to delete",
146 }
147
148 err := db.AddMemory(t.Context(), memory)
149 require.NoError(t, err)
150
151 memories, err := db.GetMemories(t.Context())
152 require.NoError(t, err)
153 require.Len(t, memories, 1)
154
155 // Delete the memory
156 err = db.DeleteMemory(t.Context(), memory)
157 require.NoError(t, err, "Deleting existing memory should succeed")
158
159 memories, err = db.GetMemories(t.Context())
160 require.NoError(t, err)
161 assert.Empty(t, memories, "Memory should be deleted")
162
163 // Try deleting non-existent memory
164 nonExistentMemory := database.UserMemory{
165 ID: "non-existent-id",
166 }
167 err = db.DeleteMemory(t.Context(), nonExistentMemory)
168 require.NoError(t, err, "Deleting non-existent memory should not return an error")
169}
170
171func TestSearchMemories(t *testing.T) {
172 t.Parallel()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected