How to use probot - 10 common examples

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 integrations / slack / test / integration / index.js View on Github external
const { createProbot } = require('probot');
const { GitHubAPI, ProbotOctokit } = require('../../lib/github/client');
const logger = require('../../lib/logger');
const nock = require('nock');

const slackbot = require('../slackbot');
const app = require('../../lib');
const models = require('../../lib/models');

const cache = require('../../lib/cache');

const probot = createProbot({});
const robot = probot.load(app);

// raise errors in tests
robot.catchErrors = false;

// Expect there are no more pending nock requests
beforeEach(async () => nock.cleanAll());
afterEach(() => expect(nock.pendingMocks()).toEqual([]));

// Ensure there is a connection established
beforeAll(async () => {
  if (global.gc) {
    global.gc();
  }
  models.sequelize.authenticate();
});
github erickzhao / invite-contributors / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()
    plugin(robot)

    // mock github api
    github = {
      orgs: {
        getOrgMembership: expect.createSpy().andThrow(new Error('Not Found')),
        addOrgMembership: expect.createSpy(),
        getTeams: expect.createSpy().andReturn(Promise.resolve({
          data: [{
            'id': 1,
            'url': 'https://api.github.com/teams/1',
            'name': 'Justice League',
            'slug': 'justice-league',
            'description': 'A great team.',
            'privacy': 'closed',
            'permission': 'admin',
github mithro / autolabeler / test / index.js View on Github external
beforeEach(() => {
    // Create a new Robot to run our plugin
    robot = createRobot()

    // Load the plugin
    plugin(robot)

    // Mock out the GitHub API
    github = {
      repos: {
        // Response for getting content from '.github/ISSUE_REPLY_TEMPLATE.md'
        getContent: expect.createSpy().andReturn(Promise.resolve({
          data: {
            content: Buffer.from(config).toString('base64')
          }
        }))
      },

      pullRequests: {
github probot / autoresponder / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()

    // Load the plugin
    plugin(robot)

    // Mock out the GitHub API
    github = {
      repos: {
        // Response for getting content from '.github/ISSUE_REPLY_TEMPLATE.md'
        getContent: expect.createSpy().andReturn(Promise.resolve({
          data: {
            content: Buffer.from(`Hello World!`).toString('base64')
          }
        }))
      },

      issues: {
github tbarn / guys-bot / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()
    plugin(robot)
    // This is an easy way to mock out the GitHub API
    github = {
      issues: {
        createComment: expect.createSpy().andReturn(Promise.resolve({
          // Whatever the GitHub API should return
        }))
      }
    }
    // Passes the mocked out GitHub API into out robot instance
    robot.auth = () => Promise.resolve(github)
  })
github probot / reminders / test / index.js View on Github external
beforeEach(() => {
    robot = createRobot()

    // Deep clone so later modifications don't mutate this.
    commentEvent = JSON.parse(JSON.stringify(require('./fixtures/issue_comment.created')))
    issue = {
      body: 'hello world\n\n',
      number: 2,
      labels: [{
        url: 'https://api.github.com/repos/baxterthehacker/public-repo/labels/reminder',
        name: 'reminder',
        color: 'fc2929'
      }]
    }

    // Load the plugin
    // Mock out the GitHub API
    github = {
github integrations / jira / test / setup / app.js View on Github external
.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 philschatz / project-bot / test / index.spec.js View on Github external
beforeEach(() => {
    nock.cleanAll()
    probot = new Probot({ githubToken: 'faketoken' })
    const app = probot.load(projectBot)
    // just return a test token
    app.app = () => 'test'
  })