Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert.equal(
data[2].local.idl['meta.json'].version,
now + 1000,
'Correct meta.json version'
);
assert.equal(
data[2].local.idl['meta.json'].remotes['github.com/org/a'].time,
(new Date(now + 1000)).toISOString(),
'Correct version of A'
);
// Fetch B locally
assert.equal(
data[3].local.idl['github.com'].org.b['service.thrift'],
thriftIdl('B'),
'Correct thrift B file locally'
);
assert.equal(
data[3].local.idl['meta.json'].version,
now + 2000,
'Correct meta.json version'
);
assert.equal(
data[3].local.idl['meta.json'].remotes['github.com/org/b'].time,
(new Date(now + 2000)).toISOString(),
'Correct version of B'
);
assert.equal(
data[1].upstream.files['idl/github.com/org/b/service.thrift'],
thriftIdl('B'),
'Correct thrift B file'
);
assert.equal(
data[1].upstream.meta.version,
now + 2000,
'Correct version'
);
// Fetch A locally
assert.equal(
data[2].local.idl['github.com'].org.a['service.thrift'],
thriftIdl('A'),
'Correct thrift A file locally'
);
assert.equal(
data[2].local.idl['meta.json'].version,
now + 1000,
'Correct meta.json version'
);
assert.equal(
data[2].local.idl['meta.json'].remotes['github.com/org/a'].time,
(new Date(now + 1000)).toISOString(),
'Correct version of A'
);
function onResults(err, results) {
if (err) {
assert.ifError(err);
}
var localApp = results[1].localApp;
var upstream = results[1].upstream;
var installedThriftFile =
localApp.thrift['github.com'].org.b['service.thrift'];
var installedMetaFile =
JSON.parse(localApp.thrift['github.com'].org.b['meta.json']);
// var localAppMetaFile = JSON.parse(localApp.thrift['meta.json']);
assert.equal(
installedThriftFile,
upstream.files['thrift/github.com/org/b/service.thrift'],
'Correct thrift file installed'
);
assert.deepEqual(
installedMetaFile.shasums,
upstream.meta.remotes['github.com/org/b'].shasums,
'Correct files and shasums for installed module'
);
assert.end();
var upstream = results[1].upstream;
var installedThriftFile =
localApp.thrift['github.com'].org.b['service.thrift'];
var installedMetaFile =
JSON.parse(localApp.thrift['github.com'].org.b['meta.json']);
// var localAppMetaFile = JSON.parse(localApp.thrift['meta.json']);
assert.equal(
installedThriftFile,
upstream.files['thrift/github.com/org/b/service.thrift'],
'Correct thrift file installed'
);
assert.deepEqual(
installedMetaFile.shasums,
upstream.meta.remotes['github.com/org/b'].shasums,
'Correct files and shasums for installed module'
);
assert.end();
}
});
// Fetch B locally
assert.equal(
data[3].local.idl['github.com'].org.b['service.thrift'],
thriftIdl('B'),
'Correct thrift B file locally'
);
assert.equal(
data[3].local.idl['meta.json'].version,
now + 2000,
'Correct meta.json version'
);
assert.equal(
data[3].local.idl['meta.json'].remotes['github.com/org/b'].time,
(new Date(now + 2000)).toISOString(),
'Correct version of B'
);
assert.equal(
data[3].local.idl['meta.json'].remotes['github.com/org/a'].time,
(new Date(now + 1000)).toISOString(),
'Correct version of A'
);
// Remote A and B updated and published. Update run.
assert.equal(
data[8].local.idl['github.com'].org.a['service.thrift'],
template(updatedThriftIdlTemplate, { remoteName: 'A' }),
'Correct thrift A file locally'
);
);
assert.equal(
data[3].local.idl['meta.json'].version,
now + 2000,
'Correct meta.json version'
);
assert.equal(
data[3].local.idl['meta.json'].remotes['github.com/org/b'].time,
(new Date(now + 2000)).toISOString(),
'Correct version of B'
);
assert.equal(
data[3].local.idl['meta.json'].remotes['github.com/org/a'].time,
(new Date(now + 1000)).toISOString(),
'Correct version of A'
);
// Remote A and B updated and published. Update run.
assert.equal(
data[8].local.idl['github.com'].org.a['service.thrift'],
template(updatedThriftIdlTemplate, { remoteName: 'A' }),
'Correct thrift A file locally'
);
assert.equal(
data[8].local.idl['github.com'].org.b['service.thrift'],
template(updatedThriftIdlTemplate, { remoteName: 'B' }),
'Correct thrift B file locally'
);
repo: 'fork0',
state: 'open',
head: 'upstreamuser:master',
}).resolves([]);
// Make the pull request
ghMock.expects('pullRequestsCreate').withArgs({
owner: 'forkuser', repo: 'fork0',
title: 'Update from upstream repo upstreamuser/repo',
head: 'upstreamuser:master',
base: 'master',
body: generateUpdateBody('upstreamuser/repo'),
maintainer_can_modify: false,
}).rejects(new Error('Explosion in the starboard engine room!'));
ghOriginal.constructor = () => gh
// inject the above mock
let {default: webhook} = proxyquire("controllers/webhookOld", {'../github': ghOriginal});
let req = {
body: {
repository: {
full_name: 'forkuser/fork0',
owner: {
login: 'forkuser',
},
name: 'fork0',
fork: true,
},
},
query: {},
reposAddCollaborator: Promise.promisify(github.repos.addCollaborator),
pullRequestsCreate: Promise.promisify(github.pullRequests.create),
pullRequestsGetAll: Promise.promisify(github.pullRequests.getAll),
pullRequestsMerge: Promise.promisify(github.pullRequests.merge),
reposCreateHook: Promise.promisify(github.repos.createHook),
reposDeleteHook: Promise.promisify(github.repos.deleteHook),
reposFork: Promise.promisify(github.repos.fork),
reposGetCollaborators: Promise.promisify(github.repos.getCollaborators),
searchIssues: Promise.promisify(github.search.issues),
};
}
// Authorize the bot.
const bot = new GitHubApi({});
bot.authenticate({
type: "oauth",
token: process.env.GITHUB_TOKEN,
});
// An express middleware that adds a github api instance to the request for the currently
// authenticated user. If no user is logged in, the property isn't set.
function authedGithubInstance(req, res, next) {
req.github = {};
// Add the bot api instance to the request.
req.github.bot = constructor(bot);
// If a user is logged in, create an add a user instance.
if (req.user) {
const github = new GitHubApi({});
import GitHubApi from 'github';
import {constructor} from './github';
// Authorize the bot.
const bot = new GitHubApi({});
bot.authenticate({
type: "oauth",
token: process.env.GITHUB_TOKEN,
});
// An express middleware that adds a github api instance to the request for the currently
// authenticated user. If no user is logged in, the property isn't set.
export default function authedGithubInstance(req, res, next) {
req.github = {};
// Add the bot api instance to the request.
req.github.bot = constructor(bot);
// If a user is logged in, create an add a user instance.
if (req.user) {
const github = new GitHubApi({});
var GitHubApi = require("github").GitHubApi;
var github = new GitHubApi();
exports.sync = function(processInfo, cb) {
var auth = processInfo.auth;
// auth.headers = {"Authorization":"token "+auth.accessToken, "Connection":"keep-alive"};
github.getUserApi().show(auth.username, function(err, profile) {
auth.profile = profile;
cb(err, {auth: auth, data : {profile : [{obj: profile}]}});
});
};