Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/api/components/getMemberInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IBMiMember } from "../types";
export class GetMemberInfo implements IBMiComponent {
static ID = 'GetMemberInfo';
private readonly procedureName = 'GETMBRINFO';
private readonly currentVersion = 1;
private readonly currentVersion = 2;
private installedVersion = 0;

reset() {
Expand Down Expand Up @@ -160,11 +160,15 @@ function getSource(library: string, name: string, version: number) {
` , rtrim( substr( Buffer, 39, 10 ) )`,
` , rtrim( substr( Buffer, 49, 10 ) )`,
` , timestamp_format( case substr( Buffer, 59, 1 )`,
` when '1' then '20' else '19' end concat `,
` substr( Buffer, 60, 12 ) , 'YYYYMMDDHH24MISS')`,
` when '1' then '20' concat substr( Buffer, 60, 12 )`,
` when '0' then '19' concat substr( Buffer, 60, 12 )`,
` else '19700101000000'`,
` end, 'YYYYMMDDHH24MISS')`,
` , timestamp_format( case substr( Buffer, 72, 1 )`,
` when '1' then '20' else '19' end concat `,
` substr( Buffer, 73, 12 ), 'YYYYMMDDHH24MISS')`,
` when '1' then '20' concat substr( Buffer, 73, 12 )`,
` when '0' then '19' concat substr( Buffer, 73, 12 )`,
` else '19700101000000'`,
` end, 'YYYYMMDDHH24MISS')`,
` , rtrim( substr( Buffer, 85, 50 ) )`,
` , case substr( Buffer, 135, 1 ) when '1' then 'Y' else 'N' end`,
` );`,
Expand Down
26 changes: 26 additions & 0 deletions src/api/tests/suites/components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,31 @@ describe('Component Tests', () => {
expect(error).toBeInstanceOf(Tools.SqlError);
expect(error.sqlstate).toBe("38501");
}

// Check getMemberInfo for empty member.
const config = connection.getConfig();
const tempLib = config!.tempLibrary,
tempSPF = `O_ABC`.concat(connection!.variantChars.local),
tempMbr = `O_ABC`.concat(connection!.variantChars.local);

const result = await connection!.runCommand({
command: `CRTSRCPF ${tempLib}/${tempSPF} MBR(${tempMbr})`,
environment: 'ile'
});

const memberInfoC = await component.getMemberInfo(connection, tempLib, tempSPF, tempMbr);
expect(memberInfoC).toBeTruthy();
expect(memberInfoC?.library).toBe(tempLib);
expect(memberInfoC?.file).toBe(tempSPF);
expect(memberInfoC?.name).toBe(tempMbr);
expect(memberInfoC?.created).toBeTypeOf('number');
expect(memberInfoC?.changed).toBeTypeOf('number');

// Cleanup...
await connection!.runCommand({
command: `DLTF ${tempLib}/${tempSPF}`,
environment: 'ile'
});

});
});
Loading