Skip to content

Commit 7ac9eb2

Browse files
committed
Fix to encoding tests
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
1 parent 556b32c commit 7ac9eb2

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

src/api/CompileTools.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface ILELibrarySettings {
1313
export namespace CompileTools {
1414
export const NEWLINE = `\r\n`;
1515
export const DID_NOT_RUN = -123;
16-
const HIDE_MESSAGE_IDS = [`CPF3485`];
16+
const HIDE_MESSAGE_IDS = [`CPF3485`, `SQL0462`];
1717

1818
const ileQueue = new SimpleQueue();
1919

@@ -125,8 +125,16 @@ export namespace CompileTools {
125125

126126
// Then fetch the job log
127127

128-
if (!options.skipDetail) {
128+
if (options.skipDetail) {
129+
// We still need to skip all the messages for the next time the commands are run
130+
const lastMessage = await connection.runSQL(`select max(ORDINAL_POSITION) as O from table(qsys2.joblog_info('*'))`);
131+
if (lastMessage && lastMessage.length === 1) {
132+
jobLogOrdinal = Number(lastMessage[0].O);
133+
}
134+
135+
} else {
129136
try {
137+
// We only care about messages since the last run :)
130138
const lastJobLog = await connection.runSQL(`select ORDINAL_POSITION, message_id, message_text from table(qsys2.joblog_info('*')) where ordinal_position > ?`, { fakeBindings: [jobLogOrdinal] });
131139
if (lastJobLog && lastJobLog.length > 0) {
132140
commandResult.stderr = lastJobLog

src/api/IBMi.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,6 @@ export default class IBMi {
13641364
const rs = await query.execute(99999);
13651365
lastResultSet = rs.data;
13661366
} catch (e: any) {
1367-
console.log(e);
13681367
error = new Tools.SqlError(e.message);
13691368
error.cause = statement
13701369

src/api/tests/connection.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ export async function newConnection(reloadSettings?: boolean) {
6565
name: `${ENV_CREDS.host}_${ENV_CREDS.username}_test`
6666
};
6767

68-
console.log(`Connecting to ${creds.username}@${creds.host}`);
69-
7068
// Override this so not to spam the console.
7169
conn.appendOutput = (data) => { };
7270

src/api/tests/setup.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@ export async function setup(project: TestProject) {
99
// When the config files exist, it makes future connections just slightly faster.
1010
// Mostly useful during the CI stage.
1111

12-
// const configsExist = exists(JSONConfig.NAME) && exists(JsonStorage.NAME);
12+
const configsExist = exists(JSONConfig.NAME) && exists(JsonStorage.NAME);
1313

14-
// if (configsExist) {
15-
// console.log(`Connection settings already existing. Skipped connection setup.`);
16-
// } else {
14+
if (configsExist) {
15+
console.log(`Connection settings already exists. Skipped connection setup.`);
16+
} else {
17+
console.log(``);
18+
console.log(`Connecting before tests run to create/refresh settings.`);
19+
const conn = await newConnection(true);
20+
await disposeConnection(conn);
1721

18-
// }
19-
20-
console.log(``);
21-
console.log(`Connecting before tests run to create/refresh settings.`);
22-
const conn = await newConnection(true);
23-
await disposeConnection(conn);
24-
25-
console.log(`Testing connection complete. Settings written/refreshed.`);
26-
console.log(``);
22+
console.log(`Testing connection complete. Settings written/refreshed.`);
23+
console.log(``);
24+
}
2725
}
2826

2927
function exists(fileName: string) {

src/api/tests/suites/encoding.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ async function runCommandsWithCCSID(connection: IBMi, commands: string[], ccsid:
2121
const config = connection.getConfig();
2222

2323
const tempLib = config.tempLibrary;
24-
const testPgmName = connection.upperCaseName(`T${commands.length}${ccsid}${Tools.makeid(2)}`);
24+
const name = `T${commands.length}${ccsid}${Tools.makeid(2)}`.padEnd(10).substring(0, 10).trim();
25+
const testPgmName = connection.upperCaseName(name);
2526

2627
await connection.runCommand({ command: `DLTOBJ OBJ(${tempLib}/${testPgmSrcFile}) OBJTYPE(*FILE)`, noLibList: true });
2728
await connection.runCommand({ command: `DLTOBJ OBJ(${tempLib}/${testPgmName}) OBJTYPE(*PGM)`, noLibList: true });
@@ -329,22 +330,22 @@ describe('Encoding tests', { concurrent: true }, () => {
329330

330331
await connection.runCommand({ command: `DLTF FILE(${tempLib}/${testFile})`, noLibList: true });
331332

332-
const createResult = await runCommandsWithCCSID(connection, [`CRTSRCPF FILE(${tempLib}/${testFile}) RCDLEN(112) CCSID(${ccsidData.userDefaultCCSID})`], ccsidData.userDefaultCCSID);
333+
const createResult = await runCommandsWithCCSID(connection, [`CRTSRCPF FILE(${tempLib}/${testFile}) RCDLEN(112) CCSID(${ccsidData.runtimeCcsid})`], ccsidData.runtimeCcsid);
333334
expect(createResult.code).toBe(0);
334335
try {
335336
const addPf = await connection.runCommand({ command: `ADDPFM FILE(${tempLib}/${testFile}) MBR(${testMember}) SRCTYPE(TXT)`, noLibList: true });
336337
expect(addPf.code).toBe(0);
337338

338339
const attributes = await connection.getContent().getAttributes({ library: tempLib, name: testFile, member: testMember }, `CCSID`);
339340
expect(attributes).toBeTruthy();
340-
expect(attributes![`CCSID`]).toBe(String(ccsidData.userDefaultCCSID));
341+
expect(attributes![`CCSID`]).toBe(String(ccsidData.runtimeCcsid));
341342

342343
const addPfB = await connection.runCommand({ command: `ADDPFM FILE(${tempLib}/${testFile}) MBR(${variantMember}) SRCTYPE(TXT)`, noLibList: true });
343344
expect(addPfB.code).toBe(0);
344345

345346
const attributesB = await connection.getContent().getAttributes({ library: tempLib, name: testFile, member: variantMember }, `CCSID`);
346347
expect(attributesB).toBeTruthy();
347-
expect(attributesB![`CCSID`]).toBe(String(ccsidData.userDefaultCCSID));
348+
expect(attributesB![`CCSID`]).toBe(String(ccsidData.runtimeCcsid));
348349

349350
const objects = await connection.getContent().getObjectList({ library: tempLib, types: [`*SRCPF`] });
350351
expect(objects.length).toBeTruthy();
@@ -366,7 +367,6 @@ describe('Encoding tests', { concurrent: true }, () => {
366367
await connection.getContent().uploadMemberContent(tempLib, testFile, testMember, [`**free`, `dsply 'Hello world';`, ` `, ` `, `return;`].join(`\n`));
367368

368369
const compileResult = await connection.runCommand({ command: `CRTBNDRPG PGM(${tempLib}/${testMember}) SRCFILE(${tempLib}/${testFile}) SRCMBR(${testMember})`, noLibList: true });
369-
console.log(compileResult);
370370
expect(compileResult.code).toBe(0);
371371

372372
await connection.runCommand({ command: `DLTOBJ OBJ(${tempLib}/${testMember}) OBJTYPE(*PGM)`, noLibList: true });

0 commit comments

Comments
 (0)