It is convenient to use `https://api.github.com/users/$app_slug[bot]` to obtain the corresponding account ID later. Then build `Signed-off-by: $app_slug[bot] <$id+$app_slug[bot]@users.noreply.github.com>`. Currently, there is no Linux environment to build test snapshot files
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import { test } from "./main.js";
|
||
|
||
// Verify `main` successfully obtains a token when the `owner` input is set (to a user), but the `repositories` input isn’t set.
|
||
await test((mockPool) => {
|
||
process.env.INPUT_OWNER = "smockle";
|
||
delete process.env.INPUT_REPOSITORIES;
|
||
|
||
// Mock installation ID and app slug request
|
||
const mockInstallationId = "123456";
|
||
const mockAppSlug = "github-actions";
|
||
mockPool
|
||
.intercept({
|
||
path: `/orgs/${process.env.INPUT_OWNER}/installation`,
|
||
method: "GET",
|
||
headers: {
|
||
accept: "application/vnd.github.v3+json",
|
||
"user-agent": "actions/create-github-app-token",
|
||
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
|
||
},
|
||
})
|
||
.reply(500, "GitHub API not available");
|
||
mockPool
|
||
.intercept({
|
||
path: `/orgs/${process.env.INPUT_OWNER}/installation`,
|
||
method: "GET",
|
||
headers: {
|
||
accept: "application/vnd.github.v3+json",
|
||
"user-agent": "actions/create-github-app-token",
|
||
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
|
||
},
|
||
})
|
||
.reply(
|
||
200,
|
||
{ id: mockInstallationId, "app_slug": mockAppSlug },
|
||
{ headers: { "content-type": "application/json" } }
|
||
);
|
||
});
|