Update test cases to support multiple mutations

Moved from GitHub dgraph-js/95

Posted by prashant-shahi:

Test cases of doRequest are failing in Dgraph master with the following error message.

[17:07:12]FAIL tests/integration/doRequest.spec.ts
[17:07:12]  ● doRequest › fails with two mutations since currently only single is supported
[17:07:12]
[17:07:12]    expect(received).rejects.toEqual()
[17:07:12]
[17:07:12]    Received promise resolved instead of rejected
[17:07:12]    Resolved to value: {"array": [undefined, [3650, 3651, undefined, [], ["1-name"]], [35336, 12262703, undefined, 1258500], undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, [["dg.3551889914.101", "0x2fc"], ["dg.3551889914.102", "0x2fb"]]], "arrayIndexOffset_": -1, "convertedPrimitiveFields_": {}, "messageId_": undefined, "pivot_": 1.7976931348623157e+308, "wrappers_": {"12": {"arrClean": true, "arr_": [["dg.3551889914.101", "0x2fc"], ["dg.3551889914.102", "0x2fb"]], "map_": {"dg.3551889914.101": {"key": "dg.3551889914.101", "value": "0x2fc", "valueWrapper": undefined}, "dg.3551889914.102": {"key": "dg.3551889914.102", "value": "0x2fb", "valueWrapper": undefined}}, "valueCtor_": null}, "2": {"array": [3650, 3651, undefined, [], ["1-name"]], "arrayIndexOffset_": -1, "convertedPrimitiveFields_": {}, "messageId_": undefined, "pivot_": 1.7976931348623157e+308, "wrappers_": null}, "3": {"array": [35336, 12262703, undefined, 1258500], "arrayIndexOffset_": -1, "convertedPrimitiveFields_": {}, "messageId_": undefined, "pivot_": 1.7976931348623157e+308, "wrappers_": null}}}
[17:07:12]
[17:07:12]      64 |         const res = client.newTxn().doRequest(req);
[17:07:12]      65 |         const ONLY_ONE_MUTATION_SUPPORTED = new Error(`${UNKNOWN_CODE}: Only 1 mutation per request is supported`);
[17:07:12]    > 66 |         await expect(res).rejects.toEqual(ONLY_ONE_MUTATION_SUPPORTED);
[17:07:12]         |               ^
[17:07:12]      67 |     });
[17:07:12]      68 | 
[17:07:12]      69 |     it("fails with zero mutations since either a mutation or a query is required", async () => {
[17:07:12]
[17:07:12]      at expect (node_modules/expect/build/index.js:138:15)
[17:07:12]      at Object.<anonymous> (tests/integration/doRequest.spec.ts:66:15)
[17:07:12]      at step (tests/integration/doRequest.spec.ts:32:23)
[17:07:12]      at Object.next (tests/integration/doRequest.spec.ts:13:53)
[17:07:12]      at fulfilled (tests/integration/doRequest.spec.ts:4:58)
[17:07:12]
[17:07:12]  ● doRequest › fails with zero mutations since either a mutation or a query is required
[17:07:12]
[17:07:12]    expect(received).rejects.toEqual(expected) // deep equality
[17:07:12]
[17:07:12]    Expected: [Error: 2 UNKNOWN: Empty query]
[17:07:12]    Received: [Error: 2 UNKNOWN: empty request]
[17:07:12]
[17:07:12]      78 |         const res = client.newTxn().doRequest(req);
[17:07:12]      79 |         const EMPTY_ERROR = new Error(`${UNKNOWN_CODE}: Empty query`);
[17:07:12]    > 80 |         await expect(res).rejects.toEqual(EMPTY_ERROR);
[17:07:12]         |                                   ^
[17:07:12]      81 |     });
[17:07:12]      82 | });
[17:07:12]      83 | 
[17:07:12]
[17:07:12]      at Object.toEqual (node_modules/expect/build/index.js:242:20)
[17:07:12]      at Object.<anonymous> (tests/integration/doRequest.spec.ts:80:35)
[17:07:12]      at step (tests/integration/doRequest.spec.ts:32:23)
[17:07:12]      at Object.next (tests/integration/doRequest.spec.ts:13:53)
[17:07:12]      at fulfilled (tests/integration/doRequest.spec.ts:4:58)

prashant-shahi commented :

Strangely, I don’t see the first test fail anymore. Reverted the changes of multiple mutations.