update tests with enterprise-slug
This commit is contained in:
@@ -5,7 +5,7 @@ import { test } from "./main.js";
|
||||
await test((mockPool) => {
|
||||
delete process.env.INPUT_OWNER;
|
||||
delete process.env.INPUT_REPOSITORIES;
|
||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||
process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise";
|
||||
|
||||
|
||||
// Mock the /app/installations endpoint to return only non-enterprise installations
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { DEFAULT_ENV } from "./main.js";
|
||||
|
||||
// Verify `main` exits with an error when `enterprise` is used with both `owner` and `repositories` inputs.
|
||||
// Verify `main` exits with an error when `enterprise-slug` is used with both `owner` and `repositories` inputs.
|
||||
try {
|
||||
// Set up environment with enterprise, owner, and repositories all set
|
||||
// Set up environment with enterprise-slug, owner, and repositories all set
|
||||
for (const [key, value] of Object.entries(DEFAULT_ENV)) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||
process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise";
|
||||
process.env.INPUT_OWNER = "test-owner";
|
||||
process.env.INPUT_REPOSITORIES = "repo1,repo2";
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { DEFAULT_ENV } from "./main.js";
|
||||
|
||||
// Verify `main` exits with an error when `enterprise` is used with `owner` input.
|
||||
// Verify `main` exits with an error when `enterprise-slug` is used with `owner` input.
|
||||
try {
|
||||
// Set up environment with enterprise and owner both set
|
||||
// Set up environment with enterprise-slug and owner set
|
||||
for (const [key, value] of Object.entries(DEFAULT_ENV)) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||
process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise";
|
||||
process.env.INPUT_OWNER = "test-owner";
|
||||
|
||||
await import("../main.js");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { DEFAULT_ENV } from "./main.js";
|
||||
|
||||
// Verify `main` exits with an error when `enterprise` is used with `repositories` input.
|
||||
// Verify `main` exits with an error when `enterprise-slug` is used with `repositories` input.
|
||||
try {
|
||||
// Set up environment with enterprise and repositories both set
|
||||
// Set up environment with enterprise-slug and repositories set
|
||||
for (const [key, value] of Object.entries(DEFAULT_ENV)) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||
process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise";
|
||||
process.env.INPUT_REPOSITORIES = "repo1,repo2";
|
||||
|
||||
await import("../main.js");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { test } from "./main.js";
|
||||
|
||||
// Verify `main` successfully obtains a token when only the `enterprise` input is set.
|
||||
// Verify `main` successfully obtains a token when only the `enterprise-slug` input is set.
|
||||
await test((mockPool) => {
|
||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||
process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise";
|
||||
delete process.env.INPUT_OWNER;
|
||||
delete process.env.INPUT_REPOSITORIES;
|
||||
|
||||
@@ -26,7 +26,7 @@ await test((mockPool) => {
|
||||
id: mockInstallationId,
|
||||
app_slug: mockAppSlug,
|
||||
target_type: "Enterprise",
|
||||
account: { login: "test-enterprise" }
|
||||
account: { login: "test-enterprise", slug: "test-enterprise" }
|
||||
}
|
||||
],
|
||||
{ headers: { "content-type": "application/json" } }
|
||||
|
||||
@@ -2,7 +2,7 @@ import { test } from "./main.js";
|
||||
|
||||
// Verify `main` successfully generates enterprise token with basic functionality.
|
||||
await test((mockPool) => {
|
||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||
process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise";
|
||||
delete process.env.INPUT_OWNER;
|
||||
delete process.env.INPUT_REPOSITORIES;
|
||||
|
||||
@@ -26,7 +26,7 @@ await test((mockPool) => {
|
||||
id: mockInstallationId,
|
||||
app_slug: mockAppSlug,
|
||||
target_type: "Enterprise",
|
||||
account: { login: "test-enterprise" }
|
||||
account: { login: "test-enterprise", slug: "test-enterprise" }
|
||||
}
|
||||
],
|
||||
{ headers: { "content-type": "application/json" } }
|
||||
|
||||
@@ -2,7 +2,7 @@ import { test } from "./main.js";
|
||||
|
||||
// Verify `main` successfully generates enterprise token with specific permissions.
|
||||
await test((mockPool) => {
|
||||
process.env.INPUT_ENTERPRISE = "test-enterprise";
|
||||
process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise";
|
||||
delete process.env.INPUT_OWNER;
|
||||
delete process.env.INPUT_REPOSITORIES;
|
||||
process.env["INPUT_PERMISSION-ENTERPRISE-ORGANIZATIONS"] = "read";
|
||||
@@ -28,7 +28,7 @@ await test((mockPool) => {
|
||||
id: mockInstallationId,
|
||||
app_slug: mockAppSlug,
|
||||
target_type: "Enterprise",
|
||||
account: { login: "test-enterprise" }
|
||||
account: { login: "test-enterprise", slug: "test-enterprise" }
|
||||
}
|
||||
],
|
||||
{ headers: { "content-type": "application/json" } }
|
||||
|
||||
+64
-24
@@ -39,6 +39,70 @@ Generated by [AVA](https://avajs.dev).
|
||||
POST /api/v3/app/installations/123456/access_tokens␊
|
||||
{"repositories":["create-github-app-token"]}`
|
||||
|
||||
## main-enterprise-installation-not-found.test.js
|
||||
|
||||
> stderr
|
||||
|
||||
`Error: No enterprise installation found matching the name test-enterprise. Available installations: Organization:some-org, User:some-user␊
|
||||
at getTokenFromEnterprise (file:///Users/s/dev/create-github-app-token/lib/main.js:229:11)␊
|
||||
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)␊
|
||||
at async RetryOperation._fn (file:///Users/s/dev/create-github-app-token/node_modules/p-retry/index.js:55:20) {␊
|
||||
attemptNumber: 1,␊
|
||||
retriesLeft: 3␊
|
||||
}`
|
||||
|
||||
> stdout
|
||||
|
||||
`Creating enterprise installation token for enterprise "test-enterprise".␊
|
||||
Failed to create token for enterprise "test-enterprise" (attempt 1): No enterprise installation found matching the name test-enterprise. Available installations: Organization:some-org, User:some-user␊
|
||||
--- REQUESTS ---␊
|
||||
GET /app/installations`
|
||||
|
||||
## main-enterprise-mutual-exclusivity-both.test.js
|
||||
|
||||
> stderr
|
||||
|
||||
`Error: Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs␊
|
||||
at main (file:///Users/s/dev/create-github-app-token/lib/main.js:31:11)␊
|
||||
at file:///Users/s/dev/create-github-app-token/main.js:33:16␊
|
||||
at ModuleJob.run (node:internal/modules/esm/module_job:274:25)␊
|
||||
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)␊
|
||||
at async file:///Users/s/dev/create-github-app-token/tests/main-enterprise-mutual-exclusivity-both.test.js:13:3`
|
||||
|
||||
> stdout
|
||||
|
||||
''
|
||||
|
||||
## main-enterprise-mutual-exclusivity-owner.test.js
|
||||
|
||||
> stderr
|
||||
|
||||
`Error: Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs␊
|
||||
at main (file:///Users/s/dev/create-github-app-token/lib/main.js:31:11)␊
|
||||
at file:///Users/s/dev/create-github-app-token/main.js:33:16␊
|
||||
at ModuleJob.run (node:internal/modules/esm/module_job:274:25)␊
|
||||
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)␊
|
||||
at async file:///Users/s/dev/create-github-app-token/tests/main-enterprise-mutual-exclusivity-owner.test.js:12:3`
|
||||
|
||||
> stdout
|
||||
|
||||
''
|
||||
|
||||
## main-enterprise-mutual-exclusivity-repositories.test.js
|
||||
|
||||
> stderr
|
||||
|
||||
`Error: Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs␊
|
||||
at main (file:///Users/s/dev/create-github-app-token/lib/main.js:31:11)␊
|
||||
at file:///Users/s/dev/create-github-app-token/main.js:33:16␊
|
||||
at ModuleJob.run (node:internal/modules/esm/module_job:274:25)␊
|
||||
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)␊
|
||||
at async file:///Users/s/dev/create-github-app-token/tests/main-enterprise-mutual-exclusivity-repositories.test.js:12:3`
|
||||
|
||||
> stdout
|
||||
|
||||
''
|
||||
|
||||
## main-enterprise-only-success.test.js
|
||||
|
||||
> stderr
|
||||
@@ -48,14 +112,6 @@ Generated by [AVA](https://avajs.dev).
|
||||
> stdout
|
||||
|
||||
`Creating enterprise installation token for enterprise "test-enterprise".␊
|
||||
### Found enterprise installation: {␊
|
||||
"id": "123456",␊
|
||||
"app_slug": "github-actions",␊
|
||||
"target_type": "Enterprise",␊
|
||||
"account": {␊
|
||||
"login": "test-enterprise"␊
|
||||
}␊
|
||||
}␊
|
||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
␊
|
||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
@@ -79,14 +135,6 @@ Generated by [AVA](https://avajs.dev).
|
||||
> stdout
|
||||
|
||||
`Creating enterprise installation token for enterprise "test-enterprise".␊
|
||||
### Found enterprise installation: {␊
|
||||
"id": "123456",␊
|
||||
"app_slug": "github-actions",␊
|
||||
"target_type": "Enterprise",␊
|
||||
"account": {␊
|
||||
"login": "test-enterprise"␊
|
||||
}␊
|
||||
}␊
|
||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
␊
|
||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
@@ -110,14 +158,6 @@ Generated by [AVA](https://avajs.dev).
|
||||
> stdout
|
||||
|
||||
`Creating enterprise installation token for enterprise "test-enterprise".␊
|
||||
### Found enterprise installation: {␊
|
||||
"id": "123456",␊
|
||||
"app_slug": "github-actions",␊
|
||||
"target_type": "Enterprise",␊
|
||||
"account": {␊
|
||||
"login": "test-enterprise"␊
|
||||
}␊
|
||||
}␊
|
||||
::add-mask::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
␊
|
||||
::set-output name=token::ghs_16C7e42F292c6912E7710c838347Ae178B4a␊
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user