(t *testing.T)
| 355 | } |
| 356 | |
| 357 | func TestInMemoryStore_Close(t *testing.T) { |
| 358 | store := NewInMemoryStore() |
| 359 | |
| 360 | ctx := context.Background() |
| 361 | require.NoError(t, store.Save(ctx, &LogicMemory{ |
| 362 | Namespace: "user:123", |
| 363 | Key: "test", |
| 364 | })) |
| 365 | |
| 366 | // 关闭存储 |
| 367 | require.NoError(t, store.Close()) |
| 368 | |
| 369 | // 所有操作应该返回 ErrStoreClosed |
| 370 | _, err := store.Get(ctx, "user:123", "test") |
| 371 | assert.ErrorIs(t, err, ErrStoreClosed) |
| 372 | |
| 373 | err = store.Save(ctx, &LogicMemory{}) |
| 374 | assert.ErrorIs(t, err, ErrStoreClosed) |
| 375 | |
| 376 | _, err = store.List(ctx, "user:123") |
| 377 | assert.ErrorIs(t, err, ErrStoreClosed) |
| 378 | } |
| 379 | |
| 380 | func TestInMemoryStore_InvalidNamespace(t *testing.T) { |
| 381 | store := NewInMemoryStore() |
nothing calls this directly
no test coverage detected