improve installation match; refactor test per copilot review
This commit is contained in:
Vendored
+2
-3
@@ -42667,12 +42667,11 @@ async function getTokenFromEnterprise(request2, auth5, enterprise2, permissions2
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const enterpriseInstallation = response.data.find(
|
const enterpriseInstallation = response.data.find(
|
||||||
(installation) => installation.target_type === "Enterprise"
|
(installation) => installation.target_type === "Enterprise" && installation.account?.slug === enterprise2
|
||||||
);
|
);
|
||||||
if (!enterpriseInstallation) {
|
if (!enterpriseInstallation) {
|
||||||
throw new Error(`No enterprise installation found. Available installations: ${response.data.map((i) => `${i.target_type}:${i.account?.login || "N/A"}`).join(", ")}`);
|
throw new Error(`No enterprise installation found matching the name ${enterprise2}. Available installations: ${response.data.map((i) => `${i.target_type}:${i.account?.login || "N/A"}`).join(", ")}`);
|
||||||
}
|
}
|
||||||
console.info(`### Found enterprise installation: ${JSON.stringify(enterpriseInstallation, null, 2)}`);
|
|
||||||
const authentication = await auth5({
|
const authentication = await auth5({
|
||||||
type: "installation",
|
type: "installation",
|
||||||
installationId: enterpriseInstallation.id,
|
installationId: enterpriseInstallation.id,
|
||||||
|
|||||||
+3
-4
@@ -221,15 +221,14 @@ async function getTokenFromEnterprise(request, auth, enterprise, permissions) {
|
|||||||
|
|
||||||
// Find the enterprise installation
|
// Find the enterprise installation
|
||||||
const enterpriseInstallation = response.data.find(
|
const enterpriseInstallation = response.data.find(
|
||||||
installation => installation.target_type === "Enterprise"
|
installation => installation.target_type === "Enterprise" &&
|
||||||
|
installation.account?.slug === enterprise
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!enterpriseInstallation) {
|
if (!enterpriseInstallation) {
|
||||||
throw new Error(`No enterprise installation found. Available installations: ${response.data.map(i => `${i.target_type}:${i.account?.login || 'N/A'}`).join(', ')}`);
|
throw new Error(`No enterprise installation found matching the name ${enterprise}. Available installations: ${response.data.map(i => `${i.target_type}:${i.account?.login || 'N/A'}`).join(', ')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info(`### Found enterprise installation: ${JSON.stringify(enterpriseInstallation, null, 2)}`);
|
|
||||||
|
|
||||||
// Get token for the enterprise installation
|
// Get token for the enterprise installation
|
||||||
const authentication = await auth({
|
const authentication = await auth({
|
||||||
type: "installation",
|
type: "installation",
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { test } from "./main.js";
|
import { test } from "./main.js";
|
||||||
delete process.env.INPUT_OWNER;
|
|
||||||
delete process.env.INPUT_REPOSITORIES;
|
|
||||||
|
|
||||||
// Verify `main` handles when no enterprise installation is found.
|
// Verify `main` handles when no enterprise installation is found.
|
||||||
await test((mockPool) => {
|
await test((mockPool) => {
|
||||||
|
delete process.env.INPUT_OWNER;
|
||||||
|
delete process.env.INPUT_REPOSITORIES;
|
||||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user