|
10 | 10 | */
|
11 | 11 |
|
12 | 12 | import { BundlePusher } from "../../../src/api/BundlePush/BundlePusher";
|
13 |
| -import { IHandlerParameters } from "@zowe/imperative"; |
| 13 | +import { IHandlerParameters, ImperativeError, IImperativeError } from "@zowe/imperative"; |
14 | 14 | import * as PushBundleDefinition from "../../../src/cli/push/bundle/PushBundle.definition";
|
15 | 15 | import * as fse from "fs-extra";
|
16 | 16 | import * as fs from "fs";
|
@@ -190,6 +190,45 @@ describe("BundlePusher01", () => {
|
190 | 190 | expect(sshSpy).toHaveBeenCalledTimes(1);
|
191 | 191 | expect(createSpy).toHaveBeenCalledTimes(1);
|
192 | 192 | });
|
| 193 | + it("should complain if remote target dir can't be found", async () => { |
| 194 | + createSpy.mockImplementationOnce(() => { |
| 195 | + const cause = "{ \"category\": 8, \"rc\": -1, \"reason\": 93651005 }"; |
| 196 | + const impError: IImperativeError = { msg: "Injected Create error", causeErrors: cause }; |
| 197 | + throw new ImperativeError(impError); |
| 198 | + }); |
| 199 | + await runPushTestWithError("__tests__/__resources__/ExampleBundle01", false, |
| 200 | + "The target directory does not exist, consider creating it by issuing: \nzowe zos-uss issue ssh \"mkdir -p /u/ThisDoesNotExist\""); |
| 201 | + |
| 202 | + expect(zosMFSpy).toHaveBeenCalledTimes(1); |
| 203 | + expect(sshSpy).toHaveBeenCalledTimes(1); |
| 204 | + expect(createSpy).toHaveBeenCalledTimes(1); |
| 205 | + }); |
| 206 | + it("should complain if remote bundle dir not auth", async () => { |
| 207 | + createSpy.mockImplementationOnce(() => { |
| 208 | + const cause = "{ \"category\": 8, \"rc\": -1, \"reason\": -276865003 }"; |
| 209 | + const impError: IImperativeError = { msg: "Injected Create error", causeErrors: cause }; |
| 210 | + throw new ImperativeError(impError); |
| 211 | + }); |
| 212 | + await runPushTestWithError("__tests__/__resources__/ExampleBundle01", false, |
| 213 | + "You are not authorized to create the target bundle directory '/u/ThisDoesNotExist/12345678'."); |
| 214 | + |
| 215 | + expect(zosMFSpy).toHaveBeenCalledTimes(1); |
| 216 | + expect(sshSpy).toHaveBeenCalledTimes(1); |
| 217 | + expect(createSpy).toHaveBeenCalledTimes(1); |
| 218 | + }); |
| 219 | + it("should not complain if remote bundle dir already exists", async () => { |
| 220 | + createSpy.mockImplementationOnce(() => { |
| 221 | + const cause = "{ \"category\": 1, \"rc\": 4, \"reason\": 19 }"; |
| 222 | + const impError: IImperativeError = { msg: "Injected Create error", causeErrors: cause }; |
| 223 | + throw new ImperativeError(impError); |
| 224 | + }); |
| 225 | + await runPushTest("__tests__/__resources__/ExampleBundle01", false, |
| 226 | + "PUSH operation completed."); |
| 227 | + |
| 228 | + expect(zosMFSpy).toHaveBeenCalledTimes(1); |
| 229 | + expect(sshSpy).toHaveBeenCalledTimes(1); |
| 230 | + expect(createSpy).toHaveBeenCalledTimes(1); |
| 231 | + }); |
193 | 232 | it("should complain if remote bundle dir error", async () => {
|
194 | 233 | listSpy.mockImplementationOnce(() => { throw new Error( "Injected List error" ); });
|
195 | 234 | await runPushTestWithError("__tests__/__resources__/ExampleBundle01", false, "Injected List error");
|
|
0 commit comments