Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-Carneiro-KX committed Mar 7, 2024
1 parent 89708c9 commit db13599
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/commands/serverCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export async function getMeta(): Promise<MetaObjectPayload | undefined> {
}
return undefined;
}

/* istanbul ignore next */
export async function getDataInsights(
targetUrl: string,
body: string,
Expand Down
34 changes: 33 additions & 1 deletion test/suite/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
});
Expand Down Expand Up @@ -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",
});
});
});
});

Expand Down

0 comments on commit db13599

Please sign in to comment.