deploy-invalidation.integration.test.ts45 lines · main
| 1 | // Integration test for CLAUDE.md §7.3 — when the deploymentId changes for |
| 2 | // an existing project, the next invocation must retire the old isolate |
| 3 | // and cold-start a fresh one against the new bundle. We assert that two |
| 4 | // invocations against the same projectId (but different deploymentIds) |
| 5 | // produce two distinct PIDs, and that each invocation returns the value |
| 6 | // from its own bundle (so we know the new deployment really took effect). |
| 7 | |
| 8 | import { describe, expect, test } from 'bun:test'; |
| 9 | |
| 10 | import { runTwoSequentialInvocations } from './test-helpers.js'; |
| 11 | |
| 12 | describe('deploy invalidation (integration)', () => { |
| 13 | test('changing deploymentId retires the old isolate and respawns fresh', async () => { |
| 14 | const { first, second, pidsObserved, cleanup } = await runTwoSequentialInvocations({ |
| 15 | first: { |
| 16 | fnName: 'v', |
| 17 | deploymentId: 'd1', |
| 18 | fnSource: ` |
| 19 | import { query } from '@briven/cli/server'; |
| 20 | export const v = query(async () => 'A'); |
| 21 | `, |
| 22 | }, |
| 23 | second: { |
| 24 | fnName: 'v', |
| 25 | deploymentId: 'd2', |
| 26 | fnSource: ` |
| 27 | import { query } from '@briven/cli/server'; |
| 28 | export const v = query(async () => 'B'); |
| 29 | `, |
| 30 | }, |
| 31 | }); |
| 32 | try { |
| 33 | expect(first.ok).toBe(true); |
| 34 | expect(second.ok).toBe(true); |
| 35 | if (first.ok) expect(first.value).toBe('A'); |
| 36 | if (second.ok) expect(second.value).toBe('B'); |
| 37 | expect(pidsObserved.length).toBeGreaterThanOrEqual(2); |
| 38 | // Two distinct PIDs prove the second invocation got a fresh isolate. |
| 39 | const unique = new Set(pidsObserved); |
| 40 | expect(unique.size).toBe(2); |
| 41 | } finally { |
| 42 | await cleanup(); |
| 43 | } |
| 44 | }, 60_000); |
| 45 | }); |