Browse Source

test(sandbox): cover workspace grant cleanup failure

Tianyi Cui 2 months ago
parent
commit
be47fcec08
1 changed files with 7 additions and 1 deletions
  1. 7 1
      packages/sandbox/sandbox-local/tests/acl-grants.spec.ts

+ 7 - 1
packages/sandbox/sandbox-local/tests/acl-grants.spec.ts

@@ -215,7 +215,7 @@ describe('windows-acl write grants (LocalSandboxProvider)', () => {
     }
     }
   })
   })
 
 
-  it('workspace grant failure disposes its SID and never creates a temp directory', async () => {
+  it('workspace grant failure disposes its SID, aggregates cleanup failure, and never creates a temp directory', async () => {
     try {
     try {
       const { sandbox } = await setup()
       const { sandbox } = await setup()
       const ws = workspaceRoot()
       const ws = workspaceRoot()
@@ -227,6 +227,12 @@ describe('windows-acl write grants (LocalSandboxProvider)', () => {
       })).toThrow('workspace grant exploded')
       })).toThrow('workspace grant exploded')
       expect(mockState.grants).toHaveLength(1)
       expect(mockState.grants).toHaveLength(1)
       expect(mockState.grants[0]!.disposed).toBe(true)
       expect(mockState.grants[0]!.disposed).toBe(true)
+
+      mockState.disposeFailure = new Error('workspace cleanup exploded')
+      expect(() => sandbox.confine(['true'], {
+        mode: 'workspace-write', workspaceRoot: ws, sessionId: SessionId('workspace-cleanup-fail'),
+      })).toThrow(/workspace grant failed and its cleanup also failed/u)
+      expect(mockState.grants).toHaveLength(2)
     } finally {
     } finally {
       cleanup()
       cleanup()
     }
     }