From db135990f820cbc4fdd76dbc067a469f73527c2f Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Thu, 7 Mar 2024 15:29:39 +0000 Subject: [PATCH] add more tests --- src/commands/serverCommand.ts | 2 +- test/suite/utils.test.ts | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/commands/serverCommand.ts b/src/commands/serverCommand.ts index d3c43c40..f7ac18ca 100644 --- a/src/commands/serverCommand.ts +++ b/src/commands/serverCommand.ts @@ -356,7 +356,7 @@ export async function getMeta(): Promise { } return undefined; } - +/* istanbul ignore next */ export async function getDataInsights( targetUrl: string, body: string, diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index dc38f250..c703e52d 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -48,6 +48,7 @@ import { } from "../../src/ipc/cClasses"; import { DataSourceTypes } from "../../src/models/dataSource"; import { InsightDetails } from "../../src/models/insights"; +import { Parse } from "../../src/ipc/parse.qlist"; interface ITestItem extends vscode.QuickPickItem { id: number; @@ -969,7 +970,30 @@ describe("Utils", () => { describe("handleWSError", () => { let sandbox: sinon.SinonSandbox; - + const abTest = new Uint8Array([ + 1, 2, 0, 0, 114, 1, 0, 0, 0, 0, 2, 0, 0, 0, 99, 11, 0, 17, 0, 0, 0, 0, + 114, 99, 118, 84, 83, 0, 99, 111, 114, 114, 0, 112, 114, 111, 116, 111, + 99, 111, 108, 0, 108, 111, 103, 67, 111, 114, 114, 0, 99, 108, 105, 101, + 110, 116, 0, 104, 116, 116, 112, 0, 97, 112, 105, 0, 117, 115, 101, 114, + 78, 97, 109, 101, 0, 117, 115, 101, 114, 73, 68, 0, 116, 105, 109, 101, + 111, 117, 116, 0, 116, 111, 0, 112, 118, 86, 101, 114, 0, 114, 101, 102, + 86, 105, 110, 116, 97, 103, 101, 0, 114, 99, 0, 97, 99, 0, 97, 105, 0, + 0, 0, 17, 0, 0, 0, 101, 0, 244, 0, 168, 200, 104, 217, 55, 151, 10, 254, + 148, 230, 16, 238, 61, 245, 76, 4, 178, 72, 184, 185, 138, 80, 65, 216, + 245, 103, 119, 0, 10, 0, 36, 0, 0, 0, 57, 52, 101, 54, 49, 48, 101, 101, + 45, 51, 100, 102, 53, 45, 52, 99, 48, 52, 45, 98, 50, 52, 56, 45, 98, + 56, 98, 57, 56, 97, 53, 48, 52, 49, 100, 56, 245, 58, 49, 48, 46, 57, + 46, 49, 51, 56, 46, 49, 57, 50, 58, 53, 48, 53, 48, 0, 245, 111, 99, + 116, 101, 116, 115, 116, 114, 101, 97, 109, 0, 245, 46, 107, 120, 105, + 46, 113, 115, 113, 108, 0, 245, 0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 249, 96, 234, 0, 0, 0, 0, 0, 0, 244, 0, 0, 16, 97, 231, + 55, 151, 10, 249, 134, 0, 0, 0, 0, 0, 0, 0, 249, 1, 0, 0, 0, 0, 0, 0, + 128, 251, 10, 0, 251, 10, 0, 10, 0, 54, 0, 0, 0, 85, 110, 101, 120, 112, + 101, 99, 116, 101, 100, 32, 101, 114, 114, 111, 114, 32, 40, 110, 49, + 48, 41, 32, 101, 110, 99, 111, 117, 110, 116, 101, 114, 101, 100, 32, + 101, 120, 101, 99, 117, 116, 105, 110, 103, 32, 46, 107, 120, 105, 46, + 113, 115, 113, 108, 0, 0, 0, 0, 0, 0, + ]); beforeEach(() => { sandbox = sinon.createSandbox(); }); @@ -999,6 +1023,14 @@ describe("Utils", () => { // Assert the result assert.deepStrictEqual(result, { error: "Query error" }); }); + + it("should handle qe/sql error", () => { + const result = queryUtils.handleWSError(abTest); + assert.deepStrictEqual(result, { + error: + "\u00006\u0000\u0000\u0000Unexpected error (n10) encountered executing .kxi.qsql\u0000\u0000\u0000\u0000\u0000", + }); + }); }); });