Revert "Propagate user_prompt_id to GenerateConentRequest for logging" (#5007)

This commit is contained in:
N. Taylor Mullen
2025-07-27 19:28:20 -07:00
committed by GitHub
parent 9ed351260c
commit bd85070411
11 changed files with 102 additions and 245 deletions

View File

@@ -14,25 +14,13 @@ vi.mock('google-auth-library');
describe('CodeAssistServer', () => {
it('should be able to be constructed', () => {
const auth = new OAuth2Client();
const server = new CodeAssistServer(
auth,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const server = new CodeAssistServer(auth, 'test-project');
expect(server).toBeInstanceOf(CodeAssistServer);
});
it('should call the generateContent endpoint', async () => {
const client = new OAuth2Client();
const server = new CodeAssistServer(
client,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const server = new CodeAssistServer(client, 'test-project');
const mockResponse = {
response: {
candidates: [
@@ -50,13 +38,10 @@ describe('CodeAssistServer', () => {
};
vi.spyOn(server, 'requestPost').mockResolvedValue(mockResponse);
const response = await server.generateContent(
{
model: 'test-model',
contents: [{ role: 'user', parts: [{ text: 'request' }] }],
},
'user-prompt-id',
);
const response = await server.generateContent({
model: 'test-model',
contents: [{ role: 'user', parts: [{ text: 'request' }] }],
});
expect(server.requestPost).toHaveBeenCalledWith(
'generateContent',
@@ -70,13 +55,7 @@ describe('CodeAssistServer', () => {
it('should call the generateContentStream endpoint', async () => {
const client = new OAuth2Client();
const server = new CodeAssistServer(
client,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const server = new CodeAssistServer(client, 'test-project');
const mockResponse = (async function* () {
yield {
response: {
@@ -96,13 +75,10 @@ describe('CodeAssistServer', () => {
})();
vi.spyOn(server, 'requestStreamingPost').mockResolvedValue(mockResponse);
const stream = await server.generateContentStream(
{
model: 'test-model',
contents: [{ role: 'user', parts: [{ text: 'request' }] }],
},
'user-prompt-id',
);
const stream = await server.generateContentStream({
model: 'test-model',
contents: [{ role: 'user', parts: [{ text: 'request' }] }],
});
for await (const res of stream) {
expect(server.requestStreamingPost).toHaveBeenCalledWith(
@@ -116,13 +92,7 @@ describe('CodeAssistServer', () => {
it('should call the onboardUser endpoint', async () => {
const client = new OAuth2Client();
const server = new CodeAssistServer(
client,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const server = new CodeAssistServer(client, 'test-project');
const mockResponse = {
name: 'operations/123',
done: true,
@@ -144,13 +114,7 @@ describe('CodeAssistServer', () => {
it('should call the loadCodeAssist endpoint', async () => {
const client = new OAuth2Client();
const server = new CodeAssistServer(
client,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const server = new CodeAssistServer(client, 'test-project');
const mockResponse = {
currentTier: {
id: UserTierId.FREE,
@@ -176,13 +140,7 @@ describe('CodeAssistServer', () => {
it('should return 0 for countTokens', async () => {
const client = new OAuth2Client();
const server = new CodeAssistServer(
client,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const server = new CodeAssistServer(client, 'test-project');
const mockResponse = {
totalTokens: 100,
};
@@ -197,13 +155,7 @@ describe('CodeAssistServer', () => {
it('should throw an error for embedContent', async () => {
const client = new OAuth2Client();
const server = new CodeAssistServer(
client,
'test-project',
{},
'test-session',
UserTierId.FREE,
);
const server = new CodeAssistServer(client, 'test-project');
await expect(
server.embedContent({
model: 'test-model',