Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default config when no config is given #20

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use default config when no config is given
  • Loading branch information
blink1073 committed Dec 24, 2023
commit ab00c4a998c634bc86069cf465e189611225de57
5 changes: 1 addition & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ interface Config {
* Get the parsed config data given a probot context.
*/
async function getConfig(context: Context<any>): Promise<Config> {
const config = await context.config('jupyterlab-probot.yml');
if (!config) {
return {};
}
const config = await context.config('jupyterlab-probot.yml') || {};
const ajv = new Ajv({ useDefaults: true });
const schema: JSONSchemaType<Config> = require('../schema.json');
const validate = ajv.compile(schema);
Expand Down
31 changes: 31 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,37 @@ describe("My Probot app", () => {

});

test("it should handle a restart comment for no config", async () => {

const mock = nock("https://api.github.com")
.persist()
.post("/app/installations/2/access_tokens")
.reply(200, {
token: "test",
permissions: {
actions: "write"
},
})

.get("/repos/hiimbex/testing-things/contents/.github%2Fjupyterlab-probot.yml")
.reply(404)

.get("/repos/hiimbex/.github/contents/.github%2Fjupyterlab-probot.yml")
.reply(404)

.patch("/repos/hiimbex/testing-things/issues/18",{"state": "closed"})
.reply(200)

.patch("/repos/hiimbex/testing-things/issues/18", {"state": "open"})
.reply(200)

// Receive a webhook event
await probot.receive({ name: "issue_comment", payload: issueComment.event });

expect(mock.pendingMocks()).toStrictEqual([]);

});

test("it should ignore a non-comment", async () => {

const config = { addBinderLink: true };
Expand Down
Loading