fix(Google BigQuery Node): Send timeoutMs in query, pagination support (#10205)

This commit is contained in:
Michael Kret
2024-07-29 21:28:16 +03:00
committed by GitHub
parent cf70b06545
commit f5722e8823
8 changed files with 80 additions and 47 deletions

View File

@@ -10,7 +10,7 @@ jest.mock('../../../v2/transport', () => {
const originalModule = jest.requireActual('../../../v2/transport');
return {
...originalModule,
googleApiRequest: jest.fn(async (method: IHttpRequestMethods, resource: string) => {
googleBigQueryApiRequest: jest.fn(async (method: IHttpRequestMethods, resource: string) => {
if (resource === '/v2/projects/test-project/jobs' && method === 'POST') {
return {
jobReference: {
@@ -25,7 +25,7 @@ jest.mock('../../../v2/transport', () => {
return {};
}
}),
// googleApiRequestAllItems: jest.fn(async () => {}),
googleBigQueryApiRequestAllItems: jest.fn(async () => ({ rows: [], schema: {} })),
};
});
@@ -47,8 +47,9 @@ describe('Test Google BigQuery V2, executeQuery', () => {
const testNode = async (testData: WorkflowTestData, types: INodeTypes) => {
const { result } = await executeWorkflow(testData, types);
expect(transport.googleApiRequest).toHaveBeenCalledTimes(2);
expect(transport.googleApiRequest).toHaveBeenCalledWith(
expect(transport.googleBigQueryApiRequest).toHaveBeenCalledTimes(1);
expect(transport.googleBigQueryApiRequestAllItems).toHaveBeenCalledTimes(1);
expect(transport.googleBigQueryApiRequest).toHaveBeenCalledWith(
'POST',
'/v2/projects/test-project/jobs',
{
@@ -60,11 +61,11 @@ describe('Test Google BigQuery V2, executeQuery', () => {
},
},
);
expect(transport.googleApiRequest).toHaveBeenCalledWith(
expect(transport.googleBigQueryApiRequestAllItems).toHaveBeenCalledWith(
'GET',
'/v2/projects/test-project/queries/job_123',
undefined,
{},
{ location: undefined, maxResults: 1000, timeoutMs: 10000 },
);
expect(result.finished).toEqual(true);