| 187 | } |
| 188 | |
| 189 | func TestInMemoryService_Delete(t *testing.T) { |
| 190 | t.Skip("Skipping: inmemory service implementation has issues with error handling") |
| 191 | ctx := context.Background() |
| 192 | |
| 193 | t.Run("删除存在的会话", func(t *testing.T) { |
| 194 | service := NewInMemoryService() |
| 195 | sess, _ := service.Create(ctx, &CreateRequest{ |
| 196 | AppName: "test-app", |
| 197 | UserID: "user-1", |
| 198 | AgentID: "agent-1", |
| 199 | }) |
| 200 | |
| 201 | err := service.Delete(ctx, sess.ID()) |
| 202 | require.NoError(t, err) |
| 203 | |
| 204 | // 验证已删除 |
| 205 | _, err = service.Get(ctx, &GetRequest{ |
| 206 | SessionID: sess.ID(), |
| 207 | }) |
| 208 | assert.ErrorIs(t, err, ErrSessionNotFound) |
| 209 | }) |
| 210 | |
| 211 | t.Run("删除不存在的会话", func(t *testing.T) { |
| 212 | service := NewInMemoryService() |
| 213 | err := service.Delete(ctx, "non-existent-id") |
| 214 | assert.ErrorIs(t, err, ErrSessionNotFound) |
| 215 | }) |
| 216 | } |
| 217 | |
| 218 | func TestInMemoryService_AppendEvent(t *testing.T) { |
| 219 | ctx := context.Background() |