Skip to content

Commit

Permalink
test(ftp/ds): Add test case for empty contents
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Sep 12, 2023
1 parent 9982386 commit 679bfc9
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,32 @@ describe("FtpMvsApi", () => {
expect(MvsApi.releaseConnection).toBeCalled();
});

it("should upload empty contents to dataset.", async () => {
const localFile = tmp.tmpNameSync({ tmpdir: "/tmp" });

fs.writeFileSync(localFile, "");
const response = TestUtils.getSingleLineStream();
DataSetUtils.listDataSets = jest.fn().mockReturnValue([{ dsname: "IBMUSER.DS2", dsorg: "PS", lrecl: 2 }]);
DataSetUtils.uploadDataSet = jest.fn().mockReturnValue(response);
jest.spyOn(MvsApi, "getContents").mockResolvedValue({ apiResponse: { etag: "123" } } as any);

const mockParams = {
inputFilePath: localFile,
dataSetName: " (IBMUSER).DS2",
options: { encoding: "", returnEtag: true, etag: "utf8" },
};

jest.spyOn(MvsApi as any, "getContentsTag").mockReturnValue(undefined);
jest.spyOn(fs, "readFileSync").mockReturnValue("");
await MvsApi.putContents(mockParams.inputFilePath, mockParams.dataSetName, mockParams.options);
expect(DataSetUtils.uploadDataSet).toHaveBeenCalledWith({ host: "", password: "", port: "", user: "" }, " (IBMUSER).DS2", {
content: " ",
encoding: "",
transferType: "ascii",
});
expect(MvsApi.releaseConnection).toBeCalled();
});

it("should create dataset.", async () => {
DataSetUtils.allocateDataSet = jest.fn();
const DATA_SET_SEQUENTIAL = 4;
Expand Down

0 comments on commit 679bfc9

Please sign in to comment.