Skip to content

Commit

Permalink
Write test case for reading members with tabs using SQL
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam authored and sebjulliand committed Mar 20, 2024
1 parent 21baac0 commit d5958c3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/filesystems/qsys/QSysFs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ export class QSysFS implements vscode.FileSystemProvider {
}

stat(uri: vscode.Uri): vscode.FileStat {
let type = uri.path.split(`/`).length > 3 ? vscode.FileType.File : vscode.FileType.Directory;

return {
ctime: 0,
mtime: 0,
size: 0,
type: vscode.FileType.File,
type,
permissions: getFilePermission(uri)
}
}
Expand Down
35 changes: 34 additions & 1 deletion src/testing/content.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import assert from "assert";
import tmp from 'tmp';
import util from 'util';
import util, { TextDecoder } from 'util';
import { Uri, workspace } from "vscode";
import { TestSuite } from ".";
import { Tools } from "../api/Tools";
import { instance } from "../instantiate";
import { CommandResult } from "../typings";
import { getMemberUri } from "../filesystems/qsys/QSysFs";

export const ContentSuite: TestSuite = {
name: `Content API tests`,
Expand Down Expand Up @@ -594,5 +595,37 @@ export const ContentSuite: TestSuite = {
assert.deepStrictEqual(resultB.OBJTEXT, "Code for i test");
}
},
{
name: `Write tab to member using SQL`, test: async () => {
const lines = [
`if (a) {`,
`\tcoolstuff();\t`,
`}`
].join(`\n`);

const connection = instance.getConnection();
const config = instance.getConfig()!;

assert.ok(config.enableSourceDates, `Source dates must be enabled for this test.`);

const tempLib = config!.tempLibrary;

await connection!.runCommand({ command: `CRTSRCPF FILE(${tempLib}/TABTEST) RCDLEN(112)`, noLibList: true });
await connection!.runCommand({ command: `ADDPFM FILE(${tempLib}/TABTEST) MBR(THEBADONE) SRCTYPE(HELLO)` });

const theBadOneUri = getMemberUri({library: tempLib, file: `TABTEST`, name: `THEBADONE`, extension: `HELLO`});

// We have to read it first to create the alias!
await workspace.fs.readFile(theBadOneUri);

await workspace.fs.writeFile(theBadOneUri, Buffer.from(lines, `utf8`));

const memberContentBuf = await workspace.fs.readFile(theBadOneUri);
const fileContent = new TextDecoder().decode(memberContentBuf)

assert.strictEqual(fileContent, lines);

}
}
]
};

0 comments on commit d5958c3

Please sign in to comment.