Skip to content

Commit 4287ffa

Browse files
committed
update UI and tests
1 parent 055cf03 commit 4287ffa

File tree

5 files changed

+40
-67
lines changed

5 files changed

+40
-67
lines changed

package.json

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
{
202202
"type": "tree",
203203
"id": "vscode-db2i.self.nodes",
204-
"name": "SELF Codes",
204+
"name": "SQL Error Logging Facility (SELF)",
205205
"when": "code-for-ibmi:connected && vscode-db2i:SELFSupported && vscode-db2i:jobManager == true",
206206
"visibility": "collapsed"
207207
}
@@ -467,7 +467,7 @@
467467
},
468468
{
469469
"command": "vscode-db2i.jobManager.editSelfCodes",
470-
"title": "Set SELF codes Level",
470+
"title": "Set logging level for SELF",
471471
"category": "Db2 for i",
472472
"icon": "$(bracket-error)"
473473
},
@@ -570,6 +570,12 @@
570570
"title": "Display SELF Code Details",
571571
"category": "Db2 for i",
572572
"icon": "$(info)"
573+
},
574+
{
575+
"command": "vscode-db2i.self.help",
576+
"title": "Open SELF Documentation",
577+
"category": "Db2 for i",
578+
"icon": "$(question)"
573579
}
574580

575581
],
@@ -700,22 +706,27 @@
700706
},
701707
{
702708
"command": "vscode-db2i.self.refresh",
703-
"group": "navigation",
709+
"group": "navigation@1",
704710
"when": "view == vscode-db2i.self.nodes"
705711
},
706712
{
707713
"command": "vscode-db2i.self.enableAutoRefresh",
708-
"group": "navigation",
714+
"group": "navigation@2",
709715
"when": "view == vscode-db2i.self.nodes && vscode-db2i.self.autoRefresh == false"
710716
},
711717
{
712718
"command": "vscode-db2i.self.disableAutoRefresh",
713-
"group": "navigation",
719+
"group": "navigation@2",
714720
"when": "view == vscode-db2i.self.nodes && vscode-db2i.self.autoRefresh == true"
715721
},
716722
{
717723
"command": "vscode-db2i.self.reset",
718-
"group": "navigation",
724+
"group": "navigation@3",
725+
"when": "view == vscode-db2i.self.nodes"
726+
},
727+
{
728+
"command": "vscode-db2i.self.help",
729+
"group": "navigation@4",
719730
"when": "view == vscode-db2i.self.nodes"
720731
},
721732
{

src/testing/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const suites : TestSuite[] = [
1212
JobsSuite,
1313
ManagerSuite,
1414
DatabaseSuite,
15+
SelfCodesTestSuite
1516
// DatabasePerformanceSuite
1617
]
1718

src/views/jobManager/jobManagerView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,18 @@ export class JobManagerView implements TreeDataProvider<any> {
150150
);
151151

152152
const quickPick = vscode.window.createQuickPick();
153-
quickPick.title = `Select SELF codes`;
153+
quickPick.title = `Set logging level for SELF`;
154154
quickPick.canSelectMany = false;
155155
quickPick.matchOnDetail = true;
156156
quickPick.items = [
157157
{
158158
kind: vscode.QuickPickItemKind.Separator,
159-
label: "Currently selected SELF codes",
159+
label: "Current logging level",
160160
},
161161
...currentSelfCodeItems,
162162
{
163163
kind: vscode.QuickPickItemKind.Separator,
164-
label: "All Available SELF codes",
164+
label: "Available logging levels",
165165
},
166166
...selfCodeItems.filter((item) =>
167167
currentSelfCodeItems

src/views/jobManager/selfCodes/selfCodesResultsView.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export class selfCodesResultsView implements TreeDataProvider<any> {
5656
});
5757
await vscode.window.showTextDocument(document, { preview: false });
5858
}
59+
}),
60+
vscode.commands.registerCommand(`vscode-db2i.self.help`, async () => {
61+
await vscode.commands.executeCommand(`vscode.open`, `https://www.ibm.com/docs/en/i/7.5?topic=tools-sql-error-logging-facility-self`)
5962
})
6063
);
6164
setInterval(async () => {

src/views/jobManager/selfCodes/selfCodesTest.ts

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,40 @@
11
import { SQLJob } from "../../../connection/sqlJob";
22
import { TestCase } from "../../../testing";
33
import assert from "assert";
4+
import { SelfCodeNode, SelfValue } from "./nodes";
5+
import { QueryResult } from "../../../connection/types";
46

57
export const selfCodeTests = [
68
{
7-
name: "SQL0138 - Left-most 1001 characters of C2",
8-
code: "138",
9-
sql: "SELECT LEFT(C2, 1001) FROM SELFTEST.MYTBL",
9+
name: "Trigger an error",
10+
code: "*ERROR",
11+
sql: "SELECT * from qsys2.noexist",
1012
},
1113
{
12-
name: "SQL0180 - Invalid format for date",
13-
code: "180",
14-
sql: "VALUES DATE('120-1231-12312')",
15-
},
16-
{
17-
name: "SQL0181 - Date that doesn't exist",
18-
code: "181",
19-
sql: "VALUES DATE('2023-45-45')",
20-
},
21-
{
22-
name: "SQL0182 - Valid datetime, invalid context",
23-
code: "182",
24-
sql: "SELECT C3/C4 FROM SELFTEST.MYTBL",
25-
},
26-
{
27-
name: "SQL0199 - Invalid syntax",
28-
code: "199",
29-
sql: "SELECT * FROM SELFTEST.MYTBL WHERE ORDER BY C1",
30-
},
31-
{
32-
name: "SQL0203 - C2 without table name",
33-
code: "203",
34-
sql: "SELECT C2 FROM SELFTEST.MYTBL T1 JOIN SELFTEST.MYTBL2 T2 ON T1.C1 = T2.C1",
35-
},
36-
{
37-
name: "SQL0204 - Table doesn't exist",
38-
code: "204",
39-
sql: "SELECT * FROM NOEXIST",
40-
},
41-
{
42-
name: "SQL0206 - Column doesn't exist",
43-
code: "206",
44-
sql: "SELECT NOCOL FROM SELFTEST.MYTBL",
45-
},
46-
{
47-
name: "SQL0420 - Can't cast varchar to int",
48-
code: "420",
49-
sql: "SELECT CAST(SELFTEST.MYTBL.C2 AS INT) FROM SELFTEST.MYTBL",
50-
},
51-
// this is a sqpecial case, need to think about how to test this one
52-
// {
53-
// name: 'SQL0551 - User profile NOGOOD has no authority',
54-
// code: '551',
55-
// sql: 'CL: CRTUSRPRF USRPRF(NOGOOD); SET SESSION AUTHORIZATION NOGOOD; SELECT * FROM SELFTEST.MYTBL2; DISCONNECT CURRENT; SET SCHEMA SELFTEST; CL: DLTUSRPRF USRPRF(NOGOOD);',
56-
// },
57-
{
58-
name: "SQL0811 - Subquery returns multiple rows",
59-
code: "811",
60-
sql: "UPDATE SELFTEST.MYTBL SET C1 = (SELECT C1 FROM SELFTEST.MYTBL2)",
61-
},
14+
name: "Tigger a warning",
15+
code: "*WARNING",
16+
sql: "SELECT LEFT(C2, 1001) FROM SELFTEST.MYTBL"
17+
}
6218
];
6319

6420
export function testSelfCodes(): TestCase[] {
6521
let tests: TestCase[] = [];
22+
const content = `SELECT job_name, matches FROM qsys2.sql_error_log where job_name = ?`;
23+
let before: string;
24+
let after: string;
6625
for (const test of selfCodeTests) {
6726
const testCase: TestCase = {
6827
name: `Self code Error for test ${test.name}`,
6928
test: async () => {
7029
let newJob = new SQLJob();
7130
await newJob.connect();
72-
await newJob.setSelfState(test.code);
31+
await newJob.setSelfState(test.code as SelfValue);
7332
try {
7433
await newJob.query(test.sql).run();
7534
} catch (e) {}
76-
77-
const content = `SELECT * FROM QSYS2.SQL_ERROR_LOG WHERE JOB_NAME = '${newJob.id}'`;
78-
let errors = await newJob.query(content).run();
79-
assert.strictEqual(errors.data.length, 1);
35+
let result = await newJob.query(content, {parameters: [newJob.id]}).run();
36+
assert(result.data[0]['MATCHES'] >= 1);
37+
8038
newJob.close();
8139
},
8240
};

0 commit comments

Comments
 (0)