fix: handle vpc-sc violations in LoadCodeAssist method (#7824)

This commit is contained in:
Gaurav
2025-09-05 19:55:33 -07:00
committed by GitHub
parent ee1b395c5c
commit a027010097
3 changed files with 90 additions and 7 deletions
@@ -215,4 +215,41 @@ describe('CodeAssistServer', () => {
}),
).rejects.toThrow();
});
it('should handle VPC-SC errors when calling loadCodeAssist', async () => {
const client = new OAuth2Client();
const server = new CodeAssistServer(
client,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const mockVpcScError = {
response: {
data: {
error: {
details: [
{
reason: 'SECURITY_POLICY_VIOLATED',
},
],
},
},
},
};
vi.spyOn(server, 'requestPost').mockRejectedValue(mockVpcScError);
const response = await server.loadCodeAssist({
metadata: {},
});
expect(server.requestPost).toHaveBeenCalledWith(
'loadCodeAssist',
expect.any(Object),
);
expect(response).toEqual({
currentTier: { id: UserTierId.STANDARD },
});
});
});