Skip to content

Commit 98d1212

Browse files
committed
fix: update create-memory test for strict strategy validation
CUSTOM is not a valid MemoryStrategyType. The previous test relied on an unsafe `as` cast to pass an invalid strategy through. Now that we use Zod parse, invalid strategies are correctly rejected.
1 parent 8202106 commit 98d1212

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/cli/operations/memory/__tests__/create-memory.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,18 @@ describe('add', () => {
7676
expect(addedMemory.strategies[0]!.namespaces).toEqual(['/users/{actorId}/facts']);
7777
});
7878

79-
it('creates memory with strategy without default namespaces', async () => {
79+
it('rejects invalid strategy type', async () => {
8080
const project = makeProject([]);
8181
mockReadProjectSpec.mockResolvedValue(project);
82-
mockWriteProjectSpec.mockResolvedValue(undefined);
8382

84-
await primitive.add({
83+
const result = await primitive.add({
8584
name: 'NewMem',
8685
strategies: 'CUSTOM',
8786
expiry: 30,
8887
});
8988

90-
const writtenSpec = mockWriteProjectSpec.mock.calls[0]![0];
91-
const addedMemory = writtenSpec.memories.find((m: { name: string }) => m.name === 'NewMem');
92-
expect(addedMemory.strategies[0]!.namespaces).toBeUndefined();
89+
expect(result).toEqual(expect.objectContaining({ success: false, error: expect.any(String) }));
90+
expect(mockWriteProjectSpec).not.toHaveBeenCalled();
9391
});
9492

9593
it('returns error on duplicate memory name', async () => {

0 commit comments

Comments
 (0)