@octopusdeploy/api-client
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -61,6 +61,6 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tasks, _a, _b, pkg; | ||
var e_1, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
var tasks, _a, _b, pkg, rejectedTasks, completedTasks, completedTasks_1, completedTasks_1_1, t, errors, rejectedTasks_1, rejectedTasks_1_1, e, error; | ||
var e_1, _c, e_2, _d, e_3, _e; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
case 0: | ||
@@ -95,5 +95,44 @@ tasks = []; | ||
} | ||
rejectedTasks = []; | ||
return [4 /*yield*/, Promise.allSettled(tasks)]; | ||
case 1: | ||
_d.sent(); | ||
completedTasks = _f.sent(); | ||
try { | ||
for (completedTasks_1 = __values(completedTasks), completedTasks_1_1 = completedTasks_1.next(); !completedTasks_1_1.done; completedTasks_1_1 = completedTasks_1.next()) { | ||
t = completedTasks_1_1.value; | ||
if (t.status === "rejected") { | ||
rejectedTasks.push(t.reason); | ||
} | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (completedTasks_1_1 && !completedTasks_1_1.done && (_d = completedTasks_1.return)) _d.call(completedTasks_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
errors = []; | ||
try { | ||
for (rejectedTasks_1 = __values(rejectedTasks), rejectedTasks_1_1 = rejectedTasks_1.next(); !rejectedTasks_1_1.done; rejectedTasks_1_1 = rejectedTasks_1.next()) { | ||
e = rejectedTasks_1_1.value; | ||
if (e instanceof Error) { | ||
errors.push(e); | ||
} | ||
else { | ||
errors.push(new Error("unexpected error: ".concat(e))); | ||
} | ||
} | ||
} | ||
catch (e_3_1) { e_3 = { error: e_3_1 }; } | ||
finally { | ||
try { | ||
if (rejectedTasks_1_1 && !rejectedTasks_1_1.done && (_e = rejectedTasks_1.return)) _e.call(rejectedTasks_1); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
} | ||
if (errors.length > 0) { | ||
error = errors.map(function (e) { return "".concat(e); }); | ||
throw new Error(error.join("\n")); | ||
} | ||
return [2 /*return*/]; | ||
@@ -100,0 +139,0 @@ } |
@@ -163,2 +163,53 @@ "use strict"; | ||
}); }); | ||
test("to a package failed", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var packageRepository, buildInformation, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
packageRepository = new packages_1.PackageRepository(client, space.Name); | ||
return [4 /*yield*/, packageRepository.push([path_1.default.join(tempOutDir, "Hello.1.0.0.zip")])]; | ||
case 1: | ||
_a.sent(); | ||
buildInformation = { | ||
spaceName: space.Name, | ||
BuildEnvironment: "BitBucket", | ||
Branch: "main", | ||
BuildNumber: "288", | ||
BuildUrl: "https://bitbucket.org/octopussamples/petclinic/addon/pipelines/home#!/results/288", | ||
VcsType: "Git", | ||
VcsRoot: "http://bitbucket.org/octopussamples/petclinic", | ||
VcsCommitNumber: "314cf2c3ee916c92a384c2796a6abe332d678e4f", | ||
Packages: [{ Id: "Hello", Version: "1.0.0" }], | ||
Commits: [ | ||
{ | ||
Id: "314cf2c3ee916c92a384c2796a6abe332d678e4f", | ||
Comment: "GOD-1 - 'test build info", | ||
}, | ||
], | ||
}; | ||
expect.assertions(2); | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, 5, , 6]); | ||
return [4 /*yield*/, new _1.BuildInformationRepository(client, space.Name).push(buildInformation)]; | ||
case 3: | ||
_a.sent(); | ||
return [4 /*yield*/, new _1.BuildInformationRepository(client, space.Name).push(buildInformation)]; | ||
case 4: | ||
_a.sent(); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
error_1 = _a.sent(); | ||
expect(error_1).toBeDefined(); | ||
if (error_1 instanceof Error) { | ||
expect(error_1.message).toContain("Metadata for the specified Package ID and version already exists."); | ||
} | ||
else { | ||
throw error_1; | ||
} | ||
return [3 /*break*/, 6]; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -165,0 +216,0 @@ return __generator(this, function (_a) { |
@@ -79,3 +79,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"jest-junit": { | ||
@@ -82,0 +82,0 @@ "outputDirectory": "reports", |
431005
8638