Skip to content

Commit 6e9ec66

Browse files
committed
fix + additional test
1 parent ea462ba commit 6e9ec66

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

lib/models/apis/pullrequest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ PullRequest.prototype.buildErrored = function (pullRequestInfo, targetUrl, cb) {
4646
}
4747
var payload = {
4848
state: 'error',
49-
description: 'Select a server to build PR-' + pullRequestInfo.number,
49+
description: 'PR-' + pullRequestInfo.number + ' has failed to build on Runnable.',
5050
// we use url to differentiate between several runnable builds
5151
context: targetUrl,
5252
target_url: targetUrl,
@@ -62,7 +62,7 @@ PullRequest.prototype.serverSelectionStatus = function (pullRequestInfo, targetU
6262
}
6363
var payload = {
6464
state: 'pending',
65-
description: 'PR-' + pullRequestInfo.number + ' is ready to run on Runnable.',
65+
description: 'Select a server to build PR-' + pullRequestInfo.number,
6666
// we use url to differentiate between several runnable builds
6767
context: targetUrl,
6868
target_url: targetUrl,

lib/routes/actions/github.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ function followBranch (instancesKey) {
255255
)
256256
)
257257
),
258-
259258
// send http response & continue in background
260259
resSendAndNext('instanceIds'),
261260
// background

test/actions-github.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ describe('Github - /actions/github', function () {
144144
ctx.originalBuildsOnPushSetting = process.env.ENABLE_GITHUB_HOOKS;
145145
ctx.originaUpdateInstance = Runnable.prototype.updateInstance;
146146
ctx.originaCreateBuild = Runnable.prototype.createBuild;
147+
ctx.originaBuildBuild = Runnable.prototype.buildBuild;
147148
ctx.originalWaitForInstanceDeployed = Runnable.prototype.waitForInstanceDeployed;
148149
ctx.originalBuildErrored = PullRequest.prototype.buildErrored;
149150
ctx.originalDeploymentErrored = PullRequest.prototype.deploymentErrored;
@@ -157,6 +158,7 @@ describe('Github - /actions/github', function () {
157158
process.env.ENABLE_GITHUB_HOOKS = ctx.originalBuildsOnPushSetting;
158159
Runnable.prototype.updateInstance = ctx.originaUpdateInstance;
159160
Runnable.prototype.createBuild = ctx.originaCreateBuild;
161+
Runnable.prototype.buildBuild = ctx.originaBuildBuild;
160162
Runnable.prototype.waitForInstanceDeployed = ctx.originalWaitForInstanceDeployed;
161163
PullRequest.prototype.buildErrored = ctx.originalBuildErrored;
162164
PullRequest.prototype.deploymentErrored = ctx.originalDeploymentErrored;
@@ -180,6 +182,36 @@ describe('Github - /actions/github', function () {
180182
});
181183

182184

185+
it('should set build status to error if error happened build create', {timeout: 6000},
186+
function (done) {
187+
188+
189+
Runnable.prototype.createBuild = function (opts, cb) {
190+
cb(Boom.notFound('Build create failed'));
191+
};
192+
193+
PullRequest.prototype.buildErrored = function (pullRequest, targetUrl, cb) {
194+
expect(pullRequest).to.exist();
195+
expect(targetUrl).to.include('https://runnable.io/');
196+
cb();
197+
done();
198+
};
199+
200+
var acv = ctx.contextVersion.attrs.appCodeVersions[0];
201+
var data = {
202+
branch: 'master',
203+
repo: acv.repo,
204+
ownerId: 2
205+
};
206+
var options = hooks(data).pull_request_sync;
207+
require('./fixtures/mocks/github/users-username')(101, 'podviaznikov');
208+
require('./fixtures/mocks/docker/container-id-attach')();
209+
request.post(options, function (err, res, instancesIds) {
210+
if (err) { return done(err); }
211+
expect(instancesIds.length).to.equal(0);
212+
});
213+
});
214+
183215

184216
it('should set deployment status to error if error happened during instance update', {timeout: 6000},
185217
function (done) {

0 commit comments

Comments
 (0)