How to use the probot.Application function in probot

To help you get started, we’ve selected a few probot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github integrations / jira / test / setup / app.js View on Github external
})

  nock('https://api.github.com')
    .post(/\/installations\/[\d\w-]+\/access_tokens/)
    .reply(200, {
      token: 'mocked-token',
      expires_at: '9999-12-31T23:59:59Z'
    })
    .get('/repos/test-repo-owner/test-repo-name/contents/.github/jira.yml')
    .reply(200, {
      content: Buffer.from(`jira: ${process.env.ATLASSIAN_URL}`).toString('base64')
    })

  const configureRobot = require('../../lib/configure-robot')

  global.app = configureRobot(new Application({
    app: createGitHubApp({
      id: 12257,
      cert: findPrivateKey()
    }),
    cache: cacheManager.caching({
      store: 'memory',
      ttl: 60 * 60 // 1 hour
    })
  }))
})
github behaviorbot / sentiment-bot / test / index.js View on Github external
const createTestApp = ({ toxicity }) => {
  // PERSPECTIVE_API_KEY must be set
  process.env.PERSPECTIVE_API_KEY = 'mock-key'
  const app = new Application()
  plugin(app)

  const github = {
    repos: {
      getContent: expect.createSpy().andReturn(Promise.resolve({
        data: {
          content: Buffer.from(`
            sentimentBotToxicityThreshold: 0.3
            sentimentBotReplyComment: "That comment was toxic"`).toString('base64')
        }
      })),
      get: expect.createSpy().andReturn(Promise.resolve({
        data: {
          code_of_conduct: Buffer.from(`
            name: 'Contributor Covenenant'
            url: https://github.com/hiimbex/testing-things/blob/master/CODE_OF_CONDUCT.md`).toString('base64')
github behaviorbot / first-pr-merge / test / index.js View on Github external
beforeEach(() => {
    app = new Application()
    plugin(app)

    github = new GitHubAPI()
    app.auth = () => Promise.resolve(github)
  })
github JasonEtco / todo / tests / helpers.js View on Github external
exports.gimmeApp = () => {
  let app, github

  const logger = {
    trace: jest.fn(),
    debug: jest.fn(),
    info: jest.fn(),
    warn: jest.fn(),
    error: jest.fn(),
    fatal: jest.fn()
  }

  app = new Application({ logger })
  app.load(plugin)

  github = {
    issues: {
      create: jest.fn().mockName('issues.create'),
      createLabel: jest.fn().mockName('issues.createLabel'),
      update: jest.fn().mockName('issues.update'),
      createComment: jest.fn().mockName('issues.createComment'),
      updateComment: jest.fn().mockName('issues.updateComment'),
      listComments: jest.fn(() => Promise.resolve({ data: [] })).mockName('issues.listComments')
    },
    search: {
      issuesAndPullRequests: jest.fn(() => Promise.resolve({ data: { total_count: 0, items: [] } })).mockName('search.issuesAndPullRequests')
    },
    git: {
      getCommit: jest.fn(() => Promise.resolve({ data: { parents: [1] } })).mockName('git.getCommit')
github behaviorbot / new-pr-welcome / test / index.js View on Github external
beforeEach(() => {
        app = new Application();
        plugin(app);
        github = new GitHubAPI();
        app.auth = () => Promise.resolve(github);
    });
github eslint / eslint-github-bot / tests / plugins / auto-closer / index.js View on Github external
beforeEach(async() => {
        githubNock = nock("https://api.github.com");
        bot = new probot.Application({
            id: "test",
            cert: "test",
            cache: {
                wrap: () => Promise.resolve({ data: { token: "test" } })
            },
            app: () => "test"
        });

        const { paginate } = await bot.auth();

        bot.auth = () => Object.assign(new GitHubApi(), { paginate });

        nock.disableNetConnect();

        autoCloser(bot);
    });
github eslint / eslint-github-bot / tests / plugins / recurring-issues / index.js View on Github external
function runBot({ issueTitle, labelNames, eventTypes }) {
        issueWasCreated = false;

        const bot = new probot.Application({
            id: "test",
            cert: "test",
            cache: {
                wrap: () => Promise.resolve({ data: { token: "test" } })
            }
        });

        bot.auth = () => new GitHubApi();
        recurringIssues(bot);

        const ORGANIZATION_NAME = "test";
        const TEAM_ID = 55;

        nock("https://api.github.com")
            .get(`/repos/${ORGANIZATION_NAME}/repo-test/issues/1/events?per_page=100`)
            .reply(200, eventTypes.map(type => ({ event: type })));
github eslint / eslint-github-bot / tests / plugins / issue-archiver / index.js View on Github external
beforeEach(async() => {
        bot = new probot.Application({
            id: "test",
            cert: "test",
            cache: {
                wrap: () => Promise.resolve({ data: { token: "test" } })
            },
            app: () => "test"
        });

        const { paginate } = await bot.auth();

        bot.auth = () => Object.assign(new GitHubApi(), { paginate });

        nock.disableNetConnect();

        nock("https://api.github.com")
            .get("/app/installations")
github bobvanderlinden / probot-auto-merge / test / mock.ts View on Github external
export function createApplication (opts: {
  logger: LoggerWithTarget,
  appFn: ApplicationFunction,
  github: GitHubAPI
}): Application {
  const app = new Application()
  app.log = opts.logger
  app.auth = () => {
    return Promise.resolve(opts.github)
  }
  app.load(opts.appFn)
  return app
}
github eslint / eslint-github-bot / tests / plugins / release-monitor / index.js View on Github external
beforeAll(async() => {
        bot = new Application({
            id: "test",
            cert: "test",
            cache: {
                wrap: () => Promise.resolve({ data: { token: "test" } })
            },
            app: () => "test"
        });

        const { paginate } = await bot.auth();

        bot.auth = () => Object.assign(new GitHubApi(), { paginate });
        releaseMonitor(bot);
    });