diff --git a/src/api/IBMiContent.ts b/src/api/IBMiContent.ts index 4efed6a1d..6917d7eb9 100644 --- a/src/api/IBMiContent.ts +++ b/src/api/IBMiContent.ts @@ -473,7 +473,13 @@ export default class IBMiContent { } async getLibraries(filters: { library: string; filterType?: FilterType }) { - return this.getObjectList({ library: "QSYS", object: filters.library, types: ["*LIB"], filterType: filters.filterType }); + const libraries: IBMiObject[] = []; + for (const library of filters.library.split(",")) { + (await this.getObjectList({ library: "QSYS", object: library.trim(), types: ["*LIB"], filterType: filters.filterType })) + .filter(lib => !libraries.find(l => l.name === lib.name)) + .forEach(lib => libraries.push(lib)); + } + return libraries; } /** @@ -942,7 +948,7 @@ export default class IBMiContent { } async getAttributes(path: string | (QsysPath & { member?: string }), ...operands: AttrOperands[]) { - const localPath = typeof path === `string` ? path : {...path}; + const localPath = typeof path === `string` ? path : { ...path }; const assumeMember = typeof localPath === `object`; let target: string; @@ -961,11 +967,11 @@ export default class IBMiContent { if (assumeMember) { target = IBMi.escapeForShell(target); - result = await this.ibmi.sendQsh({ command: `${this.ibmi.remoteFeatures.attr} -p ${target} ${operands.join(" ")}`}); + result = await this.ibmi.sendQsh({ command: `${this.ibmi.remoteFeatures.attr} -p ${target} ${operands.join(" ")}` }); } else { target = Tools.escapePath(target, true); // Take {DOES_THIS_WORK: `YESITDOES`} away, and all of a sudden names with # aren't found. - result = await this.ibmi.sendCommand({ command: `${this.ibmi.remoteFeatures.attr} -p "${target}" ${operands.join(" ")}`, env: {DOES_THIS_WORK: `YESITDOES`}}); + result = await this.ibmi.sendCommand({ command: `${this.ibmi.remoteFeatures.attr} -p "${target}" ${operands.join(" ")}`, env: { DOES_THIS_WORK: `YESITDOES` } }); } if (result.code === 0) { @@ -1050,7 +1056,7 @@ export default class IBMiContent { } } -function safeIsoValue(date: Date|undefined) { +function safeIsoValue(date: Date | undefined) { try { return date ? date.toISOString().slice(0, 19).replace(`T`, ` `) : ``; } catch (e) { diff --git a/src/testing/content.ts b/src/testing/content.ts index eb13ded66..742beac50 100644 --- a/src/testing/content.ts +++ b/src/testing/content.ts @@ -8,7 +8,7 @@ import { TestSuite } from "."; import { Tools } from "../api/Tools"; import { getMemberUri } from "../filesystems/qsys/QSysFs"; import { instance } from "../instantiate"; -import { CommandResult, IBMiObject } from "../typings"; +import { CommandResult } from "../typings"; export const ContentSuite: TestSuite = { name: `Content API tests`, @@ -249,51 +249,53 @@ export const ContentSuite: TestSuite = { } }, - {name: `Ensure source lines are correct`, test: async () => { - const connection = instance.getConnection(); - const config = instance.getConfig()!; + { + name: `Ensure source lines are correct`, test: async () => { + const connection = instance.getConnection(); + const config = instance.getConfig()!; - assert.ok(config.enableSourceDates, `Source dates must be enabled for this test.`); + assert.ok(config.enableSourceDates, `Source dates must be enabled for this test.`); - const tempLib = config!.tempLibrary; - const file = `LINES`; - const member = `THEMEMBER`; - - await connection!.runCommand({ command: `CRTSRCPF FILE(${tempLib}/${file}) RCDLEN(112)`, noLibList: true }); - await connection!.runCommand({ command: `ADDPFM FILE(${tempLib}/${file}) MBR(${member}) SRCTYPE(TXT)`, noLibList: true }); + const tempLib = config!.tempLibrary; + const file = `LINES`; + const member = `THEMEMBER`; + + await connection!.runCommand({ command: `CRTSRCPF FILE(${tempLib}/${file}) RCDLEN(112)`, noLibList: true }); + await connection!.runCommand({ command: `ADDPFM FILE(${tempLib}/${file}) MBR(${member}) SRCTYPE(TXT)`, noLibList: true }); - const aliasName = `${tempLib}.test_${file}_${member}`; - await connection?.runSQL(`CREATE OR REPLACE ALIAS ${aliasName} for "${tempLib}"."${file}"("${member}")`); + const aliasName = `${tempLib}.test_${file}_${member}`; + await connection?.runSQL(`CREATE OR REPLACE ALIAS ${aliasName} for "${tempLib}"."${file}"("${member}")`); - try { - await connection?.runSQL(`delete from ${aliasName}`); - } catch (e) {} + try { + await connection?.runSQL(`delete from ${aliasName}`); + } catch (e) { } - const inLines = [ - `Hello world`, - `1`, - `001`, - `0002`, - `00003`, - ] + const inLines = [ + `Hello world`, + `1`, + `001`, + `0002`, + `00003`, + ] - const lines = [ - `insert into ${aliasName} (srcseq, srcdat, srcdta)`, - `values `, - inLines.map((line, index) => `(${index + 1}.00, 0, '${line}')`).join(`, `), - ]; + const lines = [ + `insert into ${aliasName} (srcseq, srcdat, srcdta)`, + `values `, + inLines.map((line, index) => `(${index + 1}.00, 0, '${line}')`).join(`, `), + ]; - await connection?.runSQL(lines.join(` `)); + await connection?.runSQL(lines.join(` `)); - const theBadOneUri = getMemberUri({ library: tempLib, file, name: member, extension: `TXT` }); + const theBadOneUri = getMemberUri({ library: tempLib, file, name: member, extension: `TXT` }); - const memberContentBuf = await workspace.fs.readFile(theBadOneUri); - const fileContent = new TextDecoder().decode(memberContentBuf); + const memberContentBuf = await workspace.fs.readFile(theBadOneUri); + const fileContent = new TextDecoder().decode(memberContentBuf); - const outLines = fileContent.split(`\n`); + const outLines = fileContent.split(`\n`); - assert.deepStrictEqual(inLines, outLines); - }}, + assert.deepStrictEqual(inLines, outLines); + } + }, { name: `Test runSQL (basic select)`, test: async () => { @@ -486,6 +488,11 @@ export const ContentSuite: TestSuite = { const includeSYSLibraries = await content?.getLibraries({ library: "*SYS*" }); assert.notStrictEqual(includeSYSLibraries?.length, 0); assert.strictEqual(includeSYSLibraries?.every(l => l.name.includes("SYS")), true); + + const libraries = ["QSYSINC", "QGPL", "QTEMP"]; + const multipleLibraries = await content?.getLibraries({ library: libraries.join(",") }) + assert.strictEqual(multipleLibraries?.length, libraries.length); + assert.strictEqual(libraries.every(l => multipleLibraries.some(o => o.name === l)), true); } }, { @@ -631,10 +638,10 @@ export const ContentSuite: TestSuite = { assert.strictEqual(memberInfoB?.extension === `CPP`, true); assert.strictEqual(memberInfoB?.text === `C++ HEADER`, true); - try{ + try { await content?.getMemberInfo(`QSYSINC`, `H`, `OH_NONO`) } - catch(error: any){ + catch (error: any) { assert.ok(error instanceof Tools.SqlError); assert.strictEqual(error.sqlstate, "38501"); }