Prechádzať zdrojové kódy

test(api): cover the non-Error terminal escape in RemoteStream

The terminal fold's String(error) arm had no coverage; a generation
that rejects with a bare string now pins the marked gateway/internal
outcome.
imccyu 1 mesiac pred
rodič
commit
41cd24f3f6

+ 18 - 0
packages/api/gateway/tests/control-retry.client.spec.ts

@@ -118,6 +118,24 @@ describe('RemoteStream', () => {
     expect(carrierFailed).toHaveBeenNthCalledWith(2, repeated)
   })
 
+  it('folds a non-Error terminal escape into a marked gateway/internal failure', async () => {
+    const stream = new RemoteStream(hostSource(true).connection, {
+      name: 'fixture stream',
+      open: () => ({
+        [Symbol.asyncIterator]: (): AsyncIterator<string> => ({
+          next: vi.fn<() => Promise<IteratorResult<string>>>().mockRejectedValue('generation exploded'),
+        }),
+      }),
+      ended: () => new Error('fixture stream ended'),
+    })
+
+    await expect(stream[Symbol.asyncIterator]().next()).rejects.toMatchObject({
+      isDSHRemoteGatewayError: true,
+      code: 'gateway/internal',
+      message: 'generation exploded',
+    })
+  })
+
   it('passes a marked Remote failure through the terminal boundary verbatim', async () => {
     const failure = new RemoteError('gateway/internal', 'host stream failed', {})
     const stream = supervisor(hostSource(true).connection, [{ terminal: failure }])