-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* createDiscussionRepo github-api method created which fixes #56 * made changes based on feedback
- Loading branch information
Showing
6 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* createDiscussionRepo github-api method used to create a discussion repo named appInstallerName-discussions for a user/org in probot-background-check org in which discussion for users who have been hostile will be held. | ||
* @param {object} github - authenticated github client | ||
* @param {object} data | ||
* @param {string} data.appInstallerName - name of user/org who installed the app. | ||
* @returns {Promise<object>} | ||
*/ | ||
|
||
module.exports = (github, { appInstallerName }) => { | ||
return github.repos.createForOrg({ | ||
org: 'probot-background-check', | ||
name: `${appInstallerName}-discussions`, | ||
description: 'Repo to have discussions about toxic users', | ||
// private: true, | ||
auto_init: true | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`createDiscussionRepo is working 1`] = ` | ||
Array [ | ||
Array [ | ||
Object { | ||
"auto_init": true, | ||
"description": "Repo to have discussions about toxic users", | ||
"name": "test-org-discussions", | ||
"org": "probot-background-check", | ||
}, | ||
], | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const createDiscussionRepo = require('../lib/github-api/createDiscussionRepo') | ||
|
||
test('createDiscussionRepo is working', async () => { | ||
const github = { | ||
repos: { createForOrg: jest.fn() } | ||
} | ||
|
||
// Call your function, which internally calls your above mock function | ||
await createDiscussionRepo(github, { appInstallerName: 'test-org' }) | ||
|
||
// Test that your mock function has been called | ||
expect(github.repos.createForOrg).toHaveBeenCalledWith({ | ||
org: 'probot-background-check', | ||
name: 'test-org-discussions', | ||
description: 'Repo to have discussions about toxic users', | ||
// private: true, | ||
auto_init: true | ||
}) | ||
|
||
// Test that your mock function has been called with the right arguments | ||
expect(github.repos.createForOrg.mock.calls).toMatchSnapshot() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require('dotenv').config({path: '../../.env'}) | ||
const octokit = require('probot/lib/github')() | ||
|
||
const createDiscussionRepo = require('../../lib/github-api/createDiscussionRepo') | ||
|
||
module.exports = async context => { | ||
octokit.authenticate({ | ||
type: 'token', | ||
token: process.env.GITHUB_ACCESS_TOKEN | ||
}) | ||
await createDiscussionRepo(octokit, { | ||
appInstallerName: 'test-org' | ||
}) | ||
} |