Skip to content

Commit

Permalink
fix(ds): Pass correct DS name in stat when doing remote lookup (#3407)
Browse files Browse the repository at this point in the history
* fix: use path.basename and helper fn to extract DS name

Signed-off-by: Trae Yelovich <[email protected]>

* test: add unit test to verify proper DS name

Signed-off-by: Trae Yelovich <[email protected]>

* chore: update changelog

Signed-off-by: Trae Yelovich <[email protected]>

---------

Signed-off-by: Trae Yelovich <[email protected]>
Co-authored-by: Timothy Johnson <[email protected]>
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
traeok and t1m0thyj committed Jan 25, 2025
1 parent 541f335 commit f61d533
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Removed "Delete Profile" action from the "Manage Profile" menu since this action is currently not supported in Zowe Explorer. [#3037](https://github.com/zowe/zowe-explorer-vscode/issues/3037)
- Fixed an issue where the filesystem continued to use a profile with invalid credentials to fetch resources. Now, after an authentication error occurs for a profile, it cannot be used again in the filesystem until the authentication error is resolved. [#3329](https://github.com/zowe/zowe-explorer-vscode/issues/3329)
- Fixed data loss when creating a data set member with the same name as an existing member. When creating a new member, the user is now prompted to replace it if the member already exists. [[#3327](https://github.com/zowe/zowe-explorer-vscode/issues/3327)]
- Resolved user interface bug with tables that caused an inconsistent table height within the VS Code Panel. [#3389](https://github.com/zowe/zowe-explorer-vscode/pull/3389)
- Fixed an issue where opening a data set with the same starting pattern as an archived data set caused a REST API error (code 500) to appear in the editor. [#3407](https://github.com/zowe/zowe-explorer-vscode/pull/3407)

## `3.0.3`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { MockedProperty } from "../../../__mocks__/mockUtils";
import { DatasetFSProvider } from "../../../../src/trees/dataset/DatasetFSProvider";
import { ZoweExplorerApiRegister } from "../../../../src/extending/ZoweExplorerApiRegister";
import { AuthUtils } from "../../../../src/utils/AuthUtils";
import * as path from "path";
const dayjs = require("dayjs");

const testProfile = createIProfile();
Expand Down Expand Up @@ -686,6 +687,31 @@ describe("stat", () => {
remoteLookupForResourceMock.mockRestore();
getInfoForUriMock.mockRestore();
});

it("calls dataSet for PS and invalidates its data if mtime is newer", async () => {
const fakePs = Object.assign(Object.create(Object.getPrototypeOf(testEntries.ps)), testEntries.ps);
const lookupMock = jest.spyOn(DatasetFSProvider.instance as any, "lookup").mockReturnValue(fakePs);
const lookupParentDirMock = jest.spyOn(DatasetFSProvider.instance as any, "_lookupParentDirectory").mockReturnValue(testEntries.session);
const dataSetMock = jest.fn().mockResolvedValue({
success: true,
apiResponse: {
items: [{ name: "USER.DATA.PS", dsorg: "PS" }],
},
commandResponse: "",
});
const mvsApiMock = jest.spyOn(ZoweExplorerApiRegister, "getMvsApi").mockReturnValue({
dataSet: dataSetMock,
} as any);
const res = await DatasetFSProvider.instance.stat(testUris.ps);
expect(lookupMock).toHaveBeenCalledWith(testUris.ps, false);
expect(dataSetMock).toHaveBeenCalledWith(path.posix.basename(testEntries.ps.metadata.extensionRemovedFromPath()), { attributes: true });
expect(res).toStrictEqual({ ...fakePs });
expect(fakePs.wasAccessed).toBe(false);
lookupMock.mockRestore();
lookupParentDirMock.mockRestore();
mvsApiMock.mockRestore();
});

it("calls allMembers for a PDS member and invalidates its data if mtime is newer", async () => {
const fakePdsMember = Object.assign(Object.create(Object.getPrototypeOf(testEntries.pdsMember)), testEntries.pdsMember);
const lookupMock = jest.spyOn(DatasetFSProvider.instance as any, "lookup").mockReturnValue(fakePdsMember);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export class DatasetFSProvider extends BaseProvider implements vscode.FileSystem
resp = await ZoweExplorerApiRegister.getMvsApi(uriInfo.profile).allMembers(pds.name, { attributes: true });
} else {
// Data Set
resp = await ZoweExplorerApiRegister.getMvsApi(uriInfo.profile).dataSet(path.parse(uri.path).name, { attributes: true });
const dsPath = (entry.metadata as DsEntryMetadata).extensionRemovedFromPath();
resp = await ZoweExplorerApiRegister.getMvsApi(uriInfo.profile).dataSet(path.posix.basename(dsPath), {
attributes: true,
});
}
} catch (err) {
if (err instanceof Error) {
Expand Down

0 comments on commit f61d533

Please sign in to comment.