Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Remove duplicate isDisabled logic from controller (#206)
Browse files Browse the repository at this point in the history
The debuglet also has the same isDisabled check. Arguably the
controller shouldn't be doing this check at all because we do get a
valid debuggee.id back from the service and we should faithfully
report that to the client of the Controller interface. Business logic
to deal with a disabled debuggee belongs in the agent.
  • Loading branch information
ofrobots authored Dec 22, 2016
1 parent 2ec1732 commit 80cd5a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
2 changes: 0 additions & 2 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ Controller.prototype.register = function(debuggee, callback) {
new Error('unable to register, statusCode ' + response.statusCode));
} else if (!body.debuggee) {
callback(new Error('invalid response body from server'));
} else if (body.debuggee.isDisabled) {
callback('Debuggee is disabled on server');
} else {
debuggee.id = body.debuggee.id;
callback(null, body);
Expand Down
44 changes: 22 additions & 22 deletions test/test-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,28 +95,28 @@ describe('Controller API', function() {
});
});

it('should return error when debuggee is disabled', function(done) {
var scope = nock(url)
.post(api + '/debuggees/register')
.reply(200, {
debuggee: {
id: 'fake-debuggee',
isDisabled: true
},
activePeriodSec: 600,
});
var debuggee = new Debuggee({
project: 'fake-project',
uniquifier: 'fake-id',
description: 'unit test'
});
var controller = new Controller(fakeDebug);
controller.register(debuggee, function(err/*, result*/) {
assert(err, 'expected an error');
scope.done();
done();
});
});
it('should not return an error when the debuggee isDisabled',
function(done) {
var scope = nock(url)
.post(api + '/debuggees/register')
.reply(200, {
debuggee: {id: 'fake-debuggee', isDisabled: true},
activePeriodSec: 600,
});
var debuggee = new Debuggee({
project: 'fake-project',
uniquifier: 'fake-id',
description: 'unit test'
});
var controller = new Controller(fakeDebug);
controller.register(debuggee, function(err, result) {
assert.ifError(err, 'not expected an error');
assert.equal(result.debuggee.id, 'fake-debuggee');
assert.ok(result.debuggee.isDisabled);
scope.done();
done();
});
});

});

Expand Down

0 comments on commit 80cd5a1

Please sign in to comment.