From 565ea2533e3dbc3401919659163e18a8a7986553 Mon Sep 17 00:00:00 2001 From: "helmi.nour" Date: Wed, 31 May 2023 11:17:25 +0100 Subject: [PATCH] mock multipart response without relation id from arrow part name --- src/api/query/execAsyncApi.test.ts | 39 +++++++++++++++++++++++++++++ src/api/query/mocks/multipart | Bin 0 -> 1912 bytes 2 files changed, 39 insertions(+) create mode 100644 src/api/query/mocks/multipart diff --git a/src/api/query/execAsyncApi.test.ts b/src/api/query/execAsyncApi.test.ts index f1c7ec5..669b79e 100644 --- a/src/api/query/execAsyncApi.test.ts +++ b/src/api/query/execAsyncApi.test.ts @@ -14,6 +14,7 @@ * under the License. */ +import { readFileSync } from 'fs'; import nock from 'nock'; import { baseUrl, getMockConfig } from '../../testUtils'; @@ -21,6 +22,7 @@ import { TransactionAsyncState } from '../transaction/types'; import { ExecAsyncApi } from './execAsyncApi'; const path = '/transactions'; +const multipartMock = readFileSync(__dirname + '/mocks/multipart'); describe('QueryAsyncApi', () => { const api = new ExecAsyncApi(getMockConfig()); @@ -53,4 +55,41 @@ describe('QueryAsyncApi', () => { expect(result).toEqual(mockTransaction); }); + + it('should exec query async without relation id in arrow part name', async () => { + const query = 'x, x^2, x^3, x^4 from x in {1; 2; 3; 4; 5}'; + const payload = { + dbname: database, + engine_name: engine, + query: query, + nowait_durable: false, + readonly: true, + v1_inputs: [], + tags: [], + }; + const scope = nock(baseUrl).post(path, payload).reply(200, multipartMock, { + 'Content-type': + 'multipart/form-data; boundary=b11385ead6144ee0a9550db3672a7ccf', + }); + + const result = await api.execAsync(database, engine, query, [], true); + + scope.done(); + + expect(result).toEqual({ + transaction: { + id: '6bedf77c-8259-fcde-c31c-ab142a0606b9', + response_format_version: '2.0.4', + state: 'COMPLETED', + }, + results: [ + { + relationId: '', + metadata: expect.anything(), + table: expect.anything(), + }, + ], + problems: [], + }); + }); }); diff --git a/src/api/query/mocks/multipart b/src/api/query/mocks/multipart new file mode 100644 index 0000000000000000000000000000000000000000..4bd88bc6f95a8d6f68525bcdbc74779eceda099e GIT binary patch literal 1912 zcmb_c&2G~`5Z*L_nk7b2R8T57M0?`Erg457SD;F550yX^skf@C*7imOCAP6Qp{Vo) zc!C}|aNt3B1m362*t;rCm8wOVYIb&JKF@wLyD8_MAoLv<- z{2EKQF5-AR@&y7nKBZA;Q=6W#QNUc*^JFmW_kF(E>JIqO4YxcYW zd&Lq7M8Z^_APJ#PW->|fSeLaL%|-_hsS-+pzw`dx!P~vVyA&P z9%kqbAf%#eZ01t8y|`1JeeO-+VcV3xp>4Wu71>i-vI><-)uxZF%J;&<{8qBy%FVU9 z+H8mT7P%^4Veljc?GxbEcMl2qofCLE3;V`G(;@?k20TDBUOnM z6CC^{h*cn@LQp6vgIc5nYaT1W-hw}pSzL4d2{r)jX#X43!5Vp;6|x3d=a9Q)UtZ{%rJfd`at8*;Pe*BOPw&*;EZqVfk|j